Merge branch 'contract' into auth-server
This commit is contained in:
commit
097351162d
1 changed files with 21 additions and 2 deletions
|
@ -7,9 +7,13 @@ import (
|
|||
|
||||
func CreateUser(login string, password interop.Hash256) {
|
||||
ctx := storage.GetContext()
|
||||
// NOTE: maybe we should handle case where user already exists
|
||||
storedValue := storage.Get(ctx, login).(interop.Hash256)
|
||||
if storedValue != nil {
|
||||
panic("This user already exists")
|
||||
} else {
|
||||
storage.Put(ctx, login, password)
|
||||
}
|
||||
}
|
||||
|
||||
func CheckUser(login string, givenPassword interop.Hash256) {
|
||||
ctx := storage.GetReadOnlyContext()
|
||||
|
@ -21,3 +25,18 @@ func CheckUser(login string, givenPassword interop.Hash256) {
|
|||
panic("Password hashes does not match")
|
||||
}
|
||||
}
|
||||
|
||||
func DeleteUser(login string) {
|
||||
ctx := storage.GetContext()
|
||||
storage.Delete(ctx, login)
|
||||
}
|
||||
|
||||
func UpdateUser(login string, password interop.Hash256) {
|
||||
ctx := storage.GetContext()
|
||||
storedValue := storage.Get(ctx, login).(interop.Hash256)
|
||||
if storedValue == nil {
|
||||
panic("This user does not exist")
|
||||
} else {
|
||||
storage.Put(ctx, login, password)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue