feat: getUser method

This commit is contained in:
Iamnotagenius 2024-01-13 21:44:49 +03:00
parent 79e7443176
commit 39bc5251a9
No known key found for this signature in database
GPG key ID: 8D92479E65411DFA
2 changed files with 11 additions and 6 deletions

View file

@ -1,5 +1,5 @@
name: "Password storage"
sourceurl: https://git.frostfs.info/Web3N3/neowolves
safemethods: ["checkUser"]
safemethods: ["checkUser", "getUser"]
supportedstandards: []
events: []

View file

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