23 changed files with 341 additions and 54 deletions
File diff suppressed because one or more lines are too long
Binary file not shown.
@ -0,0 +1,26 @@ |
|||||
|
module.exports = function (sequelize, DataTypes) { |
||||
|
const User = sequelize.define('ha-user', { |
||||
|
username: { |
||||
|
type: DataTypes.STRING, |
||||
|
allowNull: false |
||||
|
}, |
||||
|
avatar: { |
||||
|
type: DataTypes.STRING, |
||||
|
allowNull: false |
||||
|
}, |
||||
|
password: { |
||||
|
type: DataTypes.STRING, |
||||
|
allowNull: false |
||||
|
}, |
||||
|
nickname: { |
||||
|
type: DataTypes.STRING, |
||||
|
allowNull: false |
||||
|
}, |
||||
|
email: { |
||||
|
type: DataTypes.STRING, |
||||
|
} |
||||
|
}, { |
||||
|
|
||||
|
}); |
||||
|
return User |
||||
|
}; |
@ -0,0 +1,13 @@ |
|||||
|
import { Req, Res, ReturnValue } from "#/global" |
||||
|
import { LoginUserSchema, RegisterUserSchema, UserSchema } from "@/schema" |
||||
|
import { gFail, gSuccess } from "@/util" |
||||
|
import { auth, config, method, route, validate } from "@noderun/hapi-router" |
||||
|
import * as bcrypt from "bcrypt" |
||||
|
|
||||
|
export default class { |
||||
|
@route("/clicked") |
||||
|
async clicked(request: Req, h: Res): ReturnValue { |
||||
|
// return 'aaaaaaaaaaaaaabbbbbbbbbbbbbbbb'
|
||||
|
return h.view('htmx/a.pug') |
||||
|
} |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
import { Req, Res, ReturnValue } from "#/global" |
||||
|
import { UserSchema } from "@/schema" |
||||
|
import { gFail, gSuccess } from "@/util" |
||||
|
import { auth, config, method, route, validate } from "@noderun/hapi-router" |
||||
|
import * as bcrypt from "bcrypt" |
||||
|
/** |
||||
|
* 登录界面 |
||||
|
*/ |
||||
|
export default class { |
||||
|
@method("GET") |
||||
|
@auth() |
||||
|
async index(request: Req, h: Res): ReturnValue { |
||||
|
const { id } = request.auth.credentials |
||||
|
const User = request.getModel("User") |
||||
|
let result = <any>await User.findOne({ where: { id: id } }) |
||||
|
if (result == null) { |
||||
|
return gFail(null, "不存在该用户") |
||||
|
} |
||||
|
result = result.toJSON() |
||||
|
delete result.password |
||||
|
console.log(result); |
||||
|
return h.view("views/user.pug", { userinfo: result }) |
||||
|
} |
||||
|
} |
@ -0,0 +1 @@ |
|||||
|
div aaaaaaasdaasdasdada |
@ -0,0 +1,13 @@ |
|||||
|
extends @/layout/layout |
||||
|
|
||||
|
block var |
||||
|
-title="用户信息" // 网页标题 |
||||
|
//- -hideHeader=true |
||||
|
|
||||
|
block head |
||||
|
|
||||
|
block content |
||||
|
section.section |
||||
|
.container |
||||
|
div username: #{user.username} |
||||
|
div id: #{user.id} |
Loading…
Reference in new issue