mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-01 20:19:30 +00:00
Implemented PasswordReset constructor
This commit is contained in:
@@ -1,13 +1,34 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const DatabaseConnectionPool = require('./DatabaseConnectionPool');
|
||||||
|
|
||||||
class PasswordReset {
|
class PasswordReset {
|
||||||
userId;
|
userId;
|
||||||
token;
|
token;
|
||||||
nonce;
|
nonce;
|
||||||
expires;
|
expires;
|
||||||
|
|
||||||
constructor() {
|
constructor(userId) {
|
||||||
|
const sql = `
|
||||||
|
select
|
||||||
|
token,
|
||||||
|
nonce,
|
||||||
|
expires,
|
||||||
|
userId
|
||||||
|
from passwordReset
|
||||||
|
where
|
||||||
|
userId = ?;
|
||||||
|
`;
|
||||||
|
|
||||||
|
return (async () => {
|
||||||
|
const conn = await new DatabaseConnectionPool();
|
||||||
|
const record = await conn.runQuery(sql, [ userId ]);
|
||||||
|
|
||||||
|
for (const [ k, v ] of Object.entries(record[0]))
|
||||||
|
this[k] = v;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
get user() {
|
get user() {
|
||||||
|
|||||||
Reference in New Issue
Block a user