refactor: check if user exists in CreateUser
This commit is contained in:
parent
239283288a
commit
c539ce303a
1 changed files with 6 additions and 2 deletions
|
@ -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) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue