// TokenRenewal to renew a refresh token
TokenRenewal to renew a refresh token
// TokenRenewal to renew a refresh token
func (ac AuthController) TokenRenewal(c *gin.Context) {
	type UserInput struct {
		RefreshToken string `json:"refresh_token"`
	}
	var input UserInput
	err := c.ShouldBindJSON(&input)
	if err != nil {
		fmt.Println(err)
		return
	}
	encodedKey := []byte(config.GetString(c, "rsa_private"))
	refreshTokenClaims, err := helpers.ValidateJwtToken(input.RefreshToken, encodedKey, "refresh")
	if err != nil {
		c.AbortWithError(http.StatusBadRequest, helpers.ErrorWithCode("refresh_token_invalid", "Refresh token invalid", err))
		return
	}
	dbUser, err := store.GetUserByID(c, fmt.Sprintf("%v", refreshTokenClaims["sub"]))
	if err != nil {
		c.AbortWithError(http.StatusBadRequest, helpers.ErrorWithCode("user_not_found", "User not found", err))
		return
	}
	returnToken(c, encodedKey, dbUser)
}
func ( ac AuthController ) TokenRenewal ( c * gin . Context ) { type UserInput struct { RefreshToken string `json:"refresh_token"` } var input UserInput err := c . ShouldBindJSON ( & input ) if err != nil { fmt . Println ( err ) return } encodedKey := [ ] byte ( config . GetString ( c , " " ) ) refreshTokenClaims , err := helpers . ValidateJwtToken ( input . RefreshToken , encodedKey , " " ) if err != nil { c . AbortWithError ( http . StatusBadRequest , helpers . ErrorWithCode ( " " , " " , err ) ) return } dbUser , err := store . GetUserByID ( c , fmt . Sprintf ( " " , refreshTokenClaims [ " " ] ) ) if err != nil { c . AbortWithError ( http . StatusBadRequest , helpers . ErrorWithCode ( " " , " " , err ) ) return } returnToken ( c , encodedKey , dbUser ) }
TokenRenewal to renew a refresh token
TokenRenewal to renew a refresh token