This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package util | |
| import ( | |
| "net/http" | |
| "github.com/gin-gonic/gin" | |
| ) | |
| // check for valid admin token | |
| func JWTAuth() gin.HandlerFunc { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package util | |
| import ( | |
| "bmacharia/jwt-go-rbac/model" | |
| "errors" | |
| "fmt" | |
| "os" | |
| "strconv" | |
| "strings" | |
| "time" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package controller | |
| import ( | |
| "bmacharia/jwt-go-rbac/model" | |
| "errors" | |
| "fmt" | |
| "net/http" | |
| "strconv" | |
| "github.com/gin-gonic/gin" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package controller | |
| import ( | |
| "bmacharia/jwt-go-rbac/model" | |
| "errors" | |
| "net/http" | |
| "strconv" | |
| "github.com/gin-gonic/gin" | |
| "gorm.io/gorm" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package model | |
| type Update struct { | |
| Username string `json:"username" binding:"required"` | |
| Email string `json:"email" binding:"required"` | |
| RoleID uint `gorm:"not null" json:"role_id"` | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package model | |
| type Login struct { | |
| Username string `json:"username" binding:"required"` | |
| Password string `json:"password" binding:"required"` | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package model | |
| type Register struct { | |
| Username string `json:"username" binding:"required"` | |
| Email string `json:"email" binding:"required"` | |
| Password string `json:"password" binding:"required"` | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package model | |
| import ( | |
| "bmacharia/jwt-go-rbac/database" | |
| "gorm.io/gorm" | |
| ) | |
| // Role model | |
| type Role struct { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package model | |
| import ( | |
| "bmacharia/jwt-go-rbac/database" | |
| "html" | |
| "strings" | |
| "golang.org/x/crypto/bcrypt" | |
| "gorm.io/gorm" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| // load required packages | |
| import ( | |
| "bmacharia/jwt-go-rbac/database" | |
| "fmt" | |
| "log" | |
| "github.com/gin-gonic/gin" | |
| "github.com/joho/godotenv" |
NewerOlder