初始化
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const crypto = require('crypto');
|
||||
const shortid = require('shortid');
|
||||
module.exports = {
|
||||
// 随机数(盐值)
|
||||
getRandomSalt() {
|
||||
@@ -20,4 +21,8 @@ module.exports = {
|
||||
cryptPwdVerification(password, salt, user_password_md5) {
|
||||
return this.cryptPwd(password, salt) === user_password_md5;
|
||||
},
|
||||
// 返回随机短uuid
|
||||
shortid() {
|
||||
return shortid.generate()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
module.exports = {
|
||||
//添加机构
|
||||
async add(name, general_management) {
|
||||
$db.table('Organization').data({
|
||||
oid: $components.encrypt.shortid(),
|
||||
name,
|
||||
general_management
|
||||
}).save()
|
||||
},
|
||||
}
|
||||
@@ -7,9 +7,9 @@
|
||||
* @return {boolean} 注册 是否 成功.
|
||||
*/
|
||||
module.exports = async (data) => {
|
||||
const {account, password} = data
|
||||
const {account, password, oid} = data
|
||||
const salt = app.components.encrypt.getRandomSalt()
|
||||
const md5 = app.components.encrypt.cryptPwd(password, salt)
|
||||
await app.db.table("User").data({account, password: md5, salt}).save()
|
||||
await app.db.table("User").data({account, password: md5, salt, to_oid: oid}).save()
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user