Skip to content

Commit f1aaebf

Browse files
committed
fixed data type struct and route name changed
1 parent ab30ffb commit f1aaebf

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

services/master/middlewares/jwt.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ func authenticator(c *gin.Context) (interface{}, error) {
3434
return user, nil
3535
}
3636

37+
// This function doesn't authenticate. Authentication to be done in middleware before invoking this function.
38+
// This function only gets the user details.
3739
func authenticatorForGctl(c *gin.Context) (interface{}, error) {
38-
auth := &types.Login{}
40+
auth := &types.GCTLToken{}
3941
if err := c.ShouldBind(auth); err != nil {
4042
return nil, errMissingCredentials
4143
}

services/master/routes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func NewService() http.Handler {
5555
auth.PUT("/revoke", c.RevokeToken)
5656
}
5757

58-
auth.POST("/gctltoken", m.AuthRequired(), m.LoginHandler)
58+
auth.POST("/pat", m.AuthRequired(), m.LoginHandler)
5959
router.GET("/instances", m.AuthRequired(), c.FetchAllInstancesByUser)
6060
router.POST("/gctllogin", m.JWTGctl.MiddlewareFunc(), c.GctlLogin)
6161

types/user.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,12 @@ func (pw *PasswordUpdate) GetOldPassword() string {
9999
func (pw *PasswordUpdate) GetNewPassword() string {
100100
return pw.NewPassword
101101
}
102+
103+
type GCTLToken struct {
104+
Email string `form:"email" json:"email" bson:"email" binding:"required"`
105+
Token string `form:"token" json:"token" bson:"token" binding:"required"`
106+
}
107+
108+
func (auth *GCTLToken) GetEmail() string {
109+
return auth.Email
110+
}

0 commit comments

Comments
 (0)