Compare commits
No commits in common. "a1e5a1092bcdfc88348c1c9c8ed3a5e8a642b9d9" and "521d01fb1df0046a7d84d5b148f562842c3138f1" have entirely different histories.
a1e5a1092b
...
521d01fb1d
2 changed files with 5 additions and 10 deletions
|
@ -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", "getUser"]
|
safemethods: ["checkUser"]
|
||||||
supportedstandards: []
|
supportedstandards: []
|
||||||
events: []
|
events: []
|
||||||
|
|
|
@ -16,19 +16,14 @@ func CreateUser(login string, password interop.Hash256) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckUser(login string, givenPassword interop.Hash256) {
|
func CheckUser(login string, givenPassword interop.Hash256) {
|
||||||
password := GetUser(login)
|
|
||||||
if !password.Equals(givenPassword) {
|
|
||||||
panic("Password hashes does not match")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetUser(login string) interop.Hash256 {
|
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
password := storage.Get(ctx, login).(interop.Hash256)
|
password := storage.Get(ctx, login).(interop.Hash256)
|
||||||
if password == nil {
|
if password == nil {
|
||||||
panic("The user does not exist")
|
panic("This user does not exist")
|
||||||
|
}
|
||||||
|
if !password.Equals(givenPassword) {
|
||||||
|
panic("Password hashes does not match")
|
||||||
}
|
}
|
||||||
return password
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteUser(login string) {
|
func DeleteUser(login string) {
|
||||||
|
|
Loading…
Reference in a new issue