mirror of https://github.com/tycrek/ass
parent
6338628739
commit
dc2f3937b2
@ -0,0 +1,19 @@
|
||||
import logger from '../logger';
|
||||
import { onStart, users, setUserPassword } from '../auth';
|
||||
|
||||
if (process.argv.length < 4) {
|
||||
logger.error('Missing username/unid or password');
|
||||
process.exit(1);
|
||||
} else {
|
||||
const id = process.argv[2];
|
||||
const password = process.argv[3];
|
||||
|
||||
onStart(process.argv[4] || 'auth.json')
|
||||
.then(() => {
|
||||
const user = users.find((user) => user.unid === id || user.username === id);
|
||||
if (!user) throw new Error('User not found');
|
||||
else return setUserPassword(user.unid, password);
|
||||
})
|
||||
.then(() => logger.info('Password changed successfully').callback(() => process.exit(0)))
|
||||
.catch((err) => logger.error(err).callback(() => process.exit(1)));
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
import logger from '../logger';
|
||||
import { onStart, users } from '../auth';
|
||||
import { compare } from 'bcrypt';
|
||||
|
||||
if (process.argv.length < 4) {
|
||||
logger.error('Missing username/unid or password');
|
||||
process.exit(1);
|
||||
} else {
|
||||
const id = process.argv[2];
|
||||
const password = process.argv[3];
|
||||
|
||||
onStart(process.argv[4] || 'auth.json')
|
||||
.then(() => {
|
||||
const user = users.find((user) => user.unid === id || user.username === id);
|
||||
if (!user) throw new Error('User not found');
|
||||
else return compare(password, user.passhash);
|
||||
})
|
||||
.then((result) => logger.info('Matches', `${result}`).callback(() => process.exit(0)))
|
||||
.catch((err) => logger.error(err).callback(() => process.exit(1)));
|
||||
}
|
Loading…
Reference in new issue