Commit ee221d82 by lzzzzl

新增登录校验

parent a157592d
Showing with 5 additions and 5 deletions
......@@ -36,21 +36,21 @@ func VerifyUser(name string, pwd string) (result bool, msg string) {
token := GenerateRandomString(32)
fmt.Println(token)
sessionIdMap[token] = name
return ok, "存在用户,密码正确"
return true, token
} else {
return !ok, "存在用户,密码不正确"
return false, "存在用户,密码不正确"
}
} else {
return !ok, "不存在用户"
return false, "不存在用户"
}
}
// 验证sessionID
func VerifySessionID(sessionID string) (bool, string) {
if _, ok := sessionIdMap[sessionID]; ok {
return ok, fmt.Sprintf("sessionID: %s 存在", sessionID)
return true, fmt.Sprintf("sessionID: %s 存在", sessionID)
} else {
return !ok, fmt.Sprintf("sessionID: %s 不存在", sessionID)
return false, fmt.Sprintf("sessionID: %s 不存在", sessionID)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment