MCPcopy Create free account
hub / github.com/appleboy/gin-jwt / authenticator

Function authenticator

_example/basic/server.go:123–142  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

121}
122
123func authenticator() func(c *gin.Context) (any, error) {
124 return func(c *gin.Context) (any, error) {
125 var loginVals login
126 if err := c.ShouldBind(&loginVals); err != nil {
127 return "", jwt.ErrMissingLoginValues
128 }
129 userID := loginVals.Username
130 password := loginVals.Password
131
132 if (userID == userAdmin && password == userAdmin) ||
133 (userID == "test" && password == "test") {
134 return &User{
135 UserName: userID,
136 LastName: "Bo-Yi",
137 FirstName: "Wu",
138 }, nil
139 }
140 return nil, jwt.ErrFailedAuthentication
141 }
142}
143
144func authorizator() func(c *gin.Context, data any) bool {
145 return func(c *gin.Context, data any) bool {

Callers 1

initParamsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…