session check
This commit is contained in:
parent
7e78ded5b4
commit
f7d99047d4
|
|
@ -7,19 +7,25 @@ function md5(str) {
|
||||||
|
|
||||||
module.exports = class extends Base {
|
module.exports = class extends Base {
|
||||||
async __before() {
|
async __before() {
|
||||||
const user = await this.session('user');
|
let user = await this.session('user');
|
||||||
|
user = {}
|
||||||
console.log("session user", user);
|
console.log("session user", user);
|
||||||
|
|
||||||
//获取用户的 session 信息,如果为空,返回 false 阻止后续的行为继续执行
|
if (['register', 'login'].indexOf(this.ctx.action) >= 0) {
|
||||||
// if (think.isEmpty(user)) {
|
return;
|
||||||
// return false;
|
}
|
||||||
// }
|
|
||||||
|
// 获取用户的 session 信息,如果为空,返回 false 阻止后续的行为继续执行
|
||||||
|
if (think.isEmpty(user)) {
|
||||||
|
return this.fail('NOT_LOGIN');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
indexAction() {
|
indexAction() {
|
||||||
return this.display();
|
return this.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 注册
|
||||||
async registerAction() {
|
async registerAction() {
|
||||||
try {
|
try {
|
||||||
let post = this.post();
|
let post = this.post();
|
||||||
|
|
@ -32,6 +38,7 @@ module.exports = class extends Base {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 登陆
|
||||||
async loginAction() {
|
async loginAction() {
|
||||||
try {
|
try {
|
||||||
let post = this.post();
|
let post = this.post();
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ app.controller('loginCtr', ['$scope', '$filter', '$state', '$http', '$cookieStor
|
||||||
$cookieStore.put("username", $scope.username);
|
$cookieStore.put("username", $scope.username);
|
||||||
|
|
||||||
await axios.post('login', params);
|
await axios.post('login', params);
|
||||||
|
return;
|
||||||
pubSubService.publish('loginCtr.login', { login: true });
|
pubSubService.publish('loginCtr.login', { login: true });
|
||||||
$state.go('bookmarks', {})
|
$state.go('bookmarks', {})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue