Add account APIs.

This commit is contained in:
Yang Luo
2021-02-11 22:56:08 +08:00
parent 09ffe69382
commit 3ea58a0cdc
7 changed files with 263 additions and 0 deletions

23
object/check.go Normal file
View File

@ -0,0 +1,23 @@
package object
func CheckUserRegister(userId string, password string) string {
if len(userId) == 0 || len(password) == 0 {
return "username and password cannot be blank"
} else if HasUser(userId) {
return "username already exists"
} else {
return ""
}
}
func CheckUserLogin(userId string, password string) string {
if !HasUser(userId) {
return "username does not exist, please sign up first"
}
if !IsPasswordCorrect(userId, password) {
return "password incorrect"
}
return ""
}