refactor: check if user exists in CreateUser

This commit is contained in:
teateatea 2024-01-12 17:31:25 +03:00
parent 239283288a
commit c539ce303a

View file

@ -7,8 +7,12 @@ import (
func CreateUser(login string, password interop.Hash256) { func CreateUser(login string, password interop.Hash256) {
ctx := storage.GetContext() ctx := storage.GetContext()
// NOTE: maybe we should handle case where user already exists storedValue := storage.Get(ctx, login).(interop.Hash256)
storage.Put(ctx, login, password) if storedValue != nil {
panic("This user already exists")
} else {
storage.Put(ctx, login, password)
}
} }
func CheckUser(login string, givenPassword interop.Hash256) { func CheckUser(login string, givenPassword interop.Hash256) {