Vue.use(VueAuth, {
auth: require('./components/auth'),
http: require('@websanova/vue-auth/drivers/http/axios.1.x.js'),
router: require('@websanova/vue-auth/drivers/router/vue-router.2.x.js'),
rolesVar: 'role',
loginData: {url: '/api-token-auth/', method: 'POST', redirect: '/somepage', fetchUser: true},
fetchData: {url: '/users/me/', method: 'GET', enabled: true},
refreshData: {url: '/users/me/', method: 'GET', enabled: true, interval: 5},
parseUserData: function(res) { return res; },
logoutData: {url: 'auth/logout', method: 'POST', redirect: '/login', makeRequest: false},
});
module.exports = {
request: function (req, token) {
this.options.http._setHeaders.call(this, req, { Authorization: 'Token ' + token });
},
response: function (res) {
let token = res.data.token
if (token) {
return token;
}
}
};
data() {
return {
isChecked: false,
}
},
methods: {
toggleSwitch() {
this.isChecked = !this.isChecked
this.$emit('input', this.isChecked)
},
},
props: {
value: Boolean,
},
- :class="{ 'ivu-switch-checked': isChecked }"
+ :class="{ 'ivu-switch-checked': value }"
- @click.prevent="toggleSwitch"
+ @click.prevent="$emit('input', !value)"
$validator = Validator::make($data, [
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
]);
$validator->after(function ($validator) {
// проводим проверку на соответствие с БД
if (....) {
$validator->errors()->add('key', 'Неправильный ключ');
}
}
const axios = require('axios')
export default {
methods: {
getCounters (count = 1, time = '', start) {
axios.get(this.url + 'counters/' + this.server + '/?count=' + count + '&time=' + (time || '&noCache=' + (new Date().getTime()) + Math.random()))
.then((res) => {
this.currentData= res.data[0]
})
.catch((err) => {
this.queryError = 'Нет ответа от сервера'
})
},
stopTimer () {
if (this.interval) {
window.clearInterval(this.interval)
}
},
startTimer () {
this.stopTimer()
this.interval = window.setInterval(() => {
this.getCounters()
}, 1000)
}
},
mounted () {
this.startTimer()
},
beforeDestroy () {
this.stopTimer()
}
}