23 lines
609 B
Go
23 lines
609 B
Go
package main
|
|
|
|
import (
|
|
"github.com/nspcc-dev/neo-go/pkg/interop"
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
|
)
|
|
|
|
func CreateUser(login string, password interop.Hash256) {
|
|
ctx := storage.GetContext()
|
|
// NOTE: maybe we should handle case where user already exists
|
|
storage.Put(ctx, login, password)
|
|
}
|
|
|
|
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")
|
|
}
|
|
if !password.Equals(givenPassword) {
|
|
panic("Password hashes does not match")
|
|
}
|
|
}
|