Can now get user admin status.

This commit is contained in:
2018-03-07 01:30:28 +01:00
parent 59b206bf2d
commit 858f3f5d57

View File

@@ -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;