Merge branch 'master' of git.frostfs.info:Web3N3/neowolves into integration-2

This commit is contained in:
regnersen 2024-01-14 02:22:37 +07:00
commit a1e5a1092b
2 changed files with 11 additions and 6 deletions

View file

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

View file

@ -16,16 +16,21 @@ func CreateUser(login string, password interop.Hash256) {
} }
func CheckUser(login string, givenPassword interop.Hash256) { func CheckUser(login string, givenPassword interop.Hash256) {
ctx := storage.GetReadOnlyContext() password := GetUser(login)
password := storage.Get(ctx, login).(interop.Hash256)
if password == nil {
panic("This user does not exist")
}
if !password.Equals(givenPassword) { if !password.Equals(givenPassword) {
panic("Password hashes does not match") 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) { func DeleteUser(login string) {
ctx := storage.GetContext() ctx := storage.GetContext()
storage.Delete(ctx, login) storage.Delete(ctx, login)