feat: getUser method
This commit is contained in:
parent
79e7443176
commit
39bc5251a9
2 changed files with 11 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
name: "Password storage"
|
||||
sourceurl: https://git.frostfs.info/Web3N3/neowolves
|
||||
safemethods: ["checkUser"]
|
||||
safemethods: ["checkUser", "getUser"]
|
||||
supportedstandards: []
|
||||
events: []
|
||||
|
|
|
@ -16,16 +16,21 @@ func CreateUser(login string, password interop.Hash256) {
|
|||
}
|
||||
|
||||
func CheckUser(login string, givenPassword interop.Hash256) {
|
||||
ctx := storage.GetReadOnlyContext()
|
||||
password := storage.Get(ctx, login).(interop.Hash256)
|
||||
if password == nil {
|
||||
panic("This user does not exist")
|
||||
}
|
||||
password := GetUser(login)
|
||||
if !password.Equals(givenPassword) {
|
||||
panic("Password hashes does not match")
|
||||
}
|
||||
}
|
||||
|
||||
func GetUser(login string) interop.Hash256 {
|
||||
ctx := storage.GetReadOnlyContext()
|
||||
password := storage.Get(ctx, login).(interop.Hash256)
|
||||
if password == nil {
|
||||
panic("The user does not exist")
|
||||
}
|
||||
return password
|
||||
}
|
||||
|
||||
func DeleteUser(login string) {
|
||||
ctx := storage.GetContext()
|
||||
storage.Delete(ctx, login)
|
||||
|
|
Loading…
Reference in a new issue