|
|
@ -12,7 +12,7 @@ import Joi from "joi"; |
|
|
|
import User from "@/model/User"; |
|
|
|
import * as bcrypt from "bcrypt"; |
|
|
|
|
|
|
|
export default class Index{ |
|
|
|
export default class Index { |
|
|
|
@auth() |
|
|
|
@config({ |
|
|
|
auth: { |
|
|
@ -20,13 +20,11 @@ export default class Index{ |
|
|
|
}, |
|
|
|
}) |
|
|
|
async index(request: Req, h: Res): ReturnValue { |
|
|
|
console.log(request.auth.isAuthenticated); |
|
|
|
// console.log(request.auth);
|
|
|
|
// if (request.isAuthenticated) {
|
|
|
|
// // 登录了
|
|
|
|
// } else {
|
|
|
|
// // 未登录
|
|
|
|
// }
|
|
|
|
if (request.auth.isAuthenticated) { |
|
|
|
// 登录了
|
|
|
|
} else { |
|
|
|
// 未登录
|
|
|
|
} |
|
|
|
return h.view("views/index.pug"); |
|
|
|
} |
|
|
|
@method("GET") |
|
|
@ -56,14 +54,13 @@ export default class Index{ |
|
|
|
async about(request, h) { |
|
|
|
console.log(request.auth); |
|
|
|
console.log(1); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
const User = request.getModel("User") |
|
|
|
|
|
|
|
console.log(await User.findOne({ where: { username: "xieyaxin" } })); |
|
|
|
const User = request.getModel("User"); |
|
|
|
|
|
|
|
console.log(await User.findOne({ where: { username: "xieyaxin" } })); |
|
|
|
} catch (error) { |
|
|
|
console.log(error); |
|
|
|
|
|
|
|
console.log(error); |
|
|
|
} |
|
|
|
console.log(2); |
|
|
|
return h.view("views/about.ejs"); |
|
|
|