-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth_token.go
48 lines (40 loc) · 1.38 KB
/
auth_token.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
42
43
44
45
46
47
48
package vcapool
/*
import (
"net/http"
"github.com/Viva-con-Agua/vcago"
)
var authCookie = vcago.NewCookieConfig()
//AuthToken represents the authentication tokens for handling access via jwt.
type AuthToken struct {
AccessToken string `json:"access_token" bson:"access_token"`
RefreshToken string `json:"refresh_token" bson:"refresh_token"`
ExpiresAt int64 `json:"expires_at" bson:"expires_at"`
}
*/
//NewAuthToken creates an new access and refresh token for the given user.
/*func NewAuthToken(user *User) (r *AuthToken, err error) {
r = new(AuthToken)
if r.AccessToken, err = NewAccessToken(user).SignedString(JWTSecret); err != nil {
return
}
r.RefreshToken, err = NewRefreshToken(user.ID).SignedString(JWTSecret)
return
}*/
/*
//AccessCookie return an cookie conains the access_token.
func (i *AuthToken) AccessCookie() (r *http.Cookie) {
return authCookie.Cookie("access_token", i.AccessToken)
}
//ResetAccessCookie returns an cookie for reset the access_token.
func ResetAccessCookie() *http.Cookie {
return authCookie.Cookie("access_token", "")
}
//RefreshCookie returns an cookie conains the refresh_token.
func (i *AuthToken) RefreshCookie() *http.Cookie {
return authCookie.Cookie("refresh_token", i.RefreshToken)
}
//ResetRefreshCookie returns an cookie for reset the refresh_token.
func ResetRefreshCookie() *http.Cookie {
return authCookie.Cookie("refresh_token", "")
}*/