Can now get user admin status.
This commit is contained in:
@@ -9,6 +9,7 @@ class UserRepository {
|
|||||||
create: 'insert into user (user_name) values (?)',
|
create: 'insert into user (user_name) values (?)',
|
||||||
change: 'update user set password = ? where user_name = ?',
|
change: 'update user set password = ? where user_name = ?',
|
||||||
retrieveHash: 'select * from user where user_name = ?',
|
retrieveHash: 'select * from user where user_name = ?',
|
||||||
|
getAdminByUser: 'select admin from user where user_name = ?'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,6 +50,12 @@ class UserRepository {
|
|||||||
changePassword(user, password) {
|
changePassword(user, password) {
|
||||||
return this.database.run(this.queries.change, [password, user.username]);
|
return this.database.run(this.queries.change, [password, user.username]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isAdmin(user) {
|
||||||
|
return this.database.get(this.queries.getAdminByUser, user.username).then((row) => {
|
||||||
|
return row.admin;
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = UserRepository;
|
module.exports = UserRepository;
|
||||||
|
|||||||
Reference in New Issue
Block a user