-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.go
41 lines (35 loc) · 1.13 KB
/
auth.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package types
import (
"database/sql"
"time"
)
// Session represents the session model
// swagger:model
type Session struct {
ID string `json:"id" gorm:"primaryKey"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
UserID string `json:"user_id"`
IsBlocked bool `json:"is_blocked" gorm:"default:false"`
ExpiresAt time.Time `json:"expires_at" gorm:"type:datetime(3)"`
IPAddress string `json:"ip_address"`
UserAgent string `json:"user_agent"`
RefreshToken sql.NullString `json:"-" gorm:"uniqueIndex:uix_users_refresh_token"`
User *User `json:"user,omitempty" gorm:"foreignKey:UserID"`
}
// AuthToken holds authentication token details with refresh token
// swagger:model
type AuthToken struct {
AccessToken string `json:"access_token,omitempty"`
TokenType string `json:"token_type,omitempty"`
ExpiresIn int `json:"expires_in,omitempty"`
RefreshToken string `json:"refresh_token,omitempty"`
}
// AuthUser represents data stored in JWT token for authenticated user
type AuthUser struct {
ID string
Name string
Email string
Role string
// add more if needed
}