mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 09:38:19 +08:00
update model.user.create() api
This commit is contained in:
1 parent
162d93e5db
commit
37756c3724
14 files changed
+31
-57
No files matched your search
@@ -11,14 +11,7 @@ export async function run({ username = '', password = '' } = {}) {
|
||||
if (username && password) {
|
||||
const udoc = await user.getById('system', -1);
|
||||
if (!udoc) {
|
||||
await user.create({
|
||||
uid: -1,
|
||||
mail: 'root@hydro.local',
|
||||
uname: username,
|
||||
password,
|
||||
regip: '127.0.0.1',
|
||||
priv: PRIV.PRIV_ALL,
|
||||
});
|
||||
await user.create('root@hydro.local', username, password, -1, '127.0.0.1', PRIV.PRIV_ALL);
|
||||
} else {
|
||||
const salt = String.random();
|
||||
await user.setById(-1, {
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
import * as user from '../model/user';
|
||||
import * as system from '../model/system';
|
||||
|
||||
export const description = 'Create a new user';
|
||||
|
||||
export async function run({
|
||||
uname, password, mail, uid,
|
||||
}) {
|
||||
if (!uid) uid = await system.inc('user');
|
||||
else uid = parseInt(uid, 10);
|
||||
if (Number.isNaN(uid)) throw new Error('uid');
|
||||
await user.create({
|
||||
uid, uname, password, mail, regip: '127.0.0.1',
|
||||
});
|
||||
if (uid) uid = parseInt(uid, 10);
|
||||
if (uid && Number.isNaN(uid)) throw new Error('uid');
|
||||
uid = await user.create(mail, uname, password, uid);
|
||||
return uid;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user