working on ron-example

This commit is contained in:
2024-11-20 23:09:25 +01:00
parent ea5d85bd19
commit 4f108e1b05
25 changed files with 627 additions and 147 deletions
+3 -3
View File
@@ -14,7 +14,7 @@ type UserPayload struct {
Role string `json:"role"`
}
func (hq *Handlers) CreateToken(c *ron.Context) {
func (hq *Handlers) CreateToken(c *ron.CTX) {
token := paseto.NewToken()
token.Set("userPayload", UserPayload{User: "pedro", Role: "admin"})
token.SetExpiration(time.Now().Add(hq.app.Security.Duration))
@@ -35,7 +35,7 @@ func (hq *Handlers) CreateToken(c *ron.Context) {
c.JSON(http.StatusOK, ron.Data{"token": signed})
}
func (hq *Handlers) ValidateTokenAuthorization(c *ron.Context) {
func (hq *Handlers) ValidateTokenAuthorization(c *ron.CTX) {
signed := c.R.Header.Get("Authorization")
split := strings.Split(signed, "Bearer ")
slog.Info("signed", "signed", split[1])
@@ -56,7 +56,7 @@ func (hq *Handlers) ValidateTokenAuthorization(c *ron.Context) {
})
}
func (hq *Handlers) ValidateTokenCookie(c *ron.Context) {
func (hq *Handlers) ValidateTokenCookie(c *ron.CTX) {
cookie, err := c.R.Cookie("token")
if err != nil {
slog.Error("error", "err", err)