Use securesign cli hash
parent
405d9345dd
commit
a7415ce381
|
@ -5,6 +5,7 @@ import nodemailer from 'nodemailer';
|
||||||
import { Message, PrivateChannel, Member, User } from 'eris';
|
import { Message, PrivateChannel, Member, User } from 'eris';
|
||||||
import uuid from 'uuid/v4';
|
import uuid from 'uuid/v4';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
import fs from 'fs';
|
||||||
import { Client } from '..';
|
import { Client } from '..';
|
||||||
import { Command, RichEmbed } from '.';
|
import { Command, RichEmbed } from '.';
|
||||||
import { ModerationInterface, AccountInterface } from '../models';
|
import { ModerationInterface, AccountInterface } from '../models';
|
||||||
|
@ -195,9 +196,13 @@ export default class Util {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param type `0` - Create
|
* @param type `0` - Create
|
||||||
|
*
|
||||||
* `1` - Warn
|
* `1` - Warn
|
||||||
|
*
|
||||||
* `2` - Lock
|
* `2` - Lock
|
||||||
|
*
|
||||||
* `3` - Unlock
|
* `3` - Unlock
|
||||||
|
*
|
||||||
* `4` - Delete
|
* `4` - Delete
|
||||||
*/
|
*/
|
||||||
public async createModerationLog(user: string, moderator: Member|User, type: number, reason?: string, duration?: number): Promise<ModerationInterface> {
|
public async createModerationLog(user: string, moderator: Member|User, type: number, reason?: string, duration?: number): Promise<ModerationInterface> {
|
||||||
|
@ -251,4 +256,12 @@ export default class Util {
|
||||||
|
|
||||||
return Promise.resolve(log);
|
return Promise.resolve(log);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getAcctHash(username: string) {
|
||||||
|
try {
|
||||||
|
return fs.readFileSync(`/home/${username}/.securesign/auth`).toString();
|
||||||
|
} catch (error) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,9 @@ export default function checkSS(client: Client) {
|
||||||
try {
|
try {
|
||||||
const accounts = await client.db.Account.find();
|
const accounts = await client.db.Account.find();
|
||||||
const hashes = accounts.filter((h) => h.hash);
|
const hashes = accounts.filter((h) => h.hash);
|
||||||
for (const { hash, userID } of hashes) {
|
for (const { userID, username } of hashes) {
|
||||||
try {
|
try {
|
||||||
|
const hash = client.util.getAcctHash(username);
|
||||||
await axios({
|
await axios({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: 'https://api.securesign.org/account/details',
|
url: 'https://api.securesign.org/account/details',
|
||||||
|
@ -17,7 +18,7 @@ export default function checkSS(client: Client) {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const { status } = error.response;
|
const { status } = error.response;
|
||||||
if (status === 400 || status === 401 || status === 403 || status === 404) {
|
if (status === 400 || status === 401 || status === 403 || status === 404) {
|
||||||
await client.db.Account.updateOne({ hash }, { $set: { hash: null } });
|
await client.db.Account.updateOne({ userID }, { $set: { hash: false } });
|
||||||
client.getDMChannel(userID).then((channel) => channel.createMessage('Your SecureSign password has been reset - please reinitialize your SecureSign account')).catch();
|
client.getDMChannel(userID).then((channel) => channel.createMessage('Your SecureSign password has been reset - please reinitialize your SecureSign account')).catch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue