MCPcopy Create free account
hub / github.com/RaymondCode/simple-demo / Register

Function Register

controller/user.go:35–58  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

33}
34
35func Register(c *gin.Context) {
36 username := c.Query("username")
37 password := c.Query("password")
38
39 token := username + password
40
41 if _, exist := usersLoginInfo[token]; exist {
42 c.JSON(http.StatusOK, UserLoginResponse{
43 Response: Response{StatusCode: 1, StatusMsg: "User already exist"},
44 })
45 } else {
46 atomic.AddInt64(&userIdSequence, 1)
47 newUser := User{
48 Id: userIdSequence,
49 Name: username,
50 }
51 usersLoginInfo[token] = newUser
52 c.JSON(http.StatusOK, UserLoginResponse{
53 Response: Response{StatusCode: 0},
54 UserId: userIdSequence,
55 Token: username + password,
56 })
57 }
58}
59
60func Login(c *gin.Context) {
61 username := c.Query("username")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected