feat: implemented controller methods for passwordresetcomplete, refresh in auth controller
This commit is contained in:
@@ -77,7 +77,6 @@ func (a *authControllerImpl) Login(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(http.StatusOK, response)
|
c.JSON(http.StatusOK, response)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Summary Request password reset email
|
// @Summary Request password reset email
|
||||||
@@ -106,7 +105,6 @@ func (a *authControllerImpl) PasswordResetBegin(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(http.StatusOK, response)
|
c.JSON(http.StatusOK, response)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Summary Complete password reset via email code
|
// @Summary Complete password reset via email code
|
||||||
@@ -118,7 +116,24 @@ func (a *authControllerImpl) PasswordResetBegin(c *gin.Context) {
|
|||||||
// @Success 200 {object} models.PasswordResetCompleteResponse " "
|
// @Success 200 {object} models.PasswordResetCompleteResponse " "
|
||||||
// @Success 403 "Wrong verification code or username"
|
// @Success 403 "Wrong verification code or username"
|
||||||
func (a *authControllerImpl) PasswordResetComplete(c *gin.Context) {
|
func (a *authControllerImpl) PasswordResetComplete(c *gin.Context) {
|
||||||
c.Status(http.StatusNotImplemented)
|
|
||||||
|
request, ok := utils.GetRequest[models.PasswordResetCompleteRequest](c)
|
||||||
|
if !ok {
|
||||||
|
c.Status(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := a.auth.PasswordResetComplete(request.Body)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, errs.ErrForbidden) {
|
||||||
|
c.Status(http.StatusForbidden)
|
||||||
|
} else {
|
||||||
|
c.Status(http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(http.StatusOK, response)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -131,7 +146,24 @@ func (a *authControllerImpl) PasswordResetComplete(c *gin.Context) {
|
|||||||
// @Success 200 {object} models.RefreshResponse " "
|
// @Success 200 {object} models.RefreshResponse " "
|
||||||
// @Failure 401 "Invalid refresh token"
|
// @Failure 401 "Invalid refresh token"
|
||||||
func (a *authControllerImpl) Refresh(c *gin.Context) {
|
func (a *authControllerImpl) Refresh(c *gin.Context) {
|
||||||
c.Status(http.StatusNotImplemented)
|
|
||||||
|
request, ok := utils.GetRequest[models.RefreshRequest](c)
|
||||||
|
if !ok {
|
||||||
|
c.Status(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := a.auth.Refresh(request.Body)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, errs.ErrUnauthorized) {
|
||||||
|
c.Status(http.StatusUnauthorized)
|
||||||
|
} else {
|
||||||
|
c.Status(http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(http.StatusOK, response)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Summary Register an account
|
// @Summary Register an account
|
||||||
|
|||||||
Reference in New Issue
Block a user