6
6
"errors"
7
7
"strings"
8
8
9
- "github.com/gistapp/api/auth"
10
9
"github.com/gistapp/api/user"
11
10
"github.com/gistapp/api/utils"
12
11
"github.com/gofiber/fiber/v2"
@@ -20,12 +19,12 @@ func (m *MockAuthService) Authenticate(c *fiber.Ctx) error {
20
19
return nil
21
20
}
22
21
23
- func (m * MockAuthService ) LocalAuth (email string ) (auth .TokenSQL , error ) {
22
+ func (m * MockAuthService ) LocalAuth (email string ) (user .TokenSQL , error ) {
24
23
token_val := utils .GenToken (6 )
25
- token_model := auth .TokenSQL {
24
+ token_model := user .TokenSQL {
26
25
Keyword : sql.NullString {String : email , Valid : true },
27
26
Value : sql.NullString {String : token_val , Valid : true },
28
- Type : sql.NullString {String : string (auth .LocalAuth ), Valid : true },
27
+ Type : sql.NullString {String : string (user .LocalAuth ), Valid : true },
29
28
}
30
29
31
30
_ , err := token_model .Save ()
@@ -35,10 +34,10 @@ func (m *MockAuthService) LocalAuth(email string) (auth.TokenSQL, error) {
35
34
}
36
35
37
36
func (m * MockAuthService ) VerifyLocalAuthToken (token string , email string ) (string , error ) {
38
- token_model := auth .TokenSQL {
37
+ token_model := user .TokenSQL {
39
38
Value : sql.NullString {String : token , Valid : true },
40
39
Keyword : sql.NullString {String : email , Valid : true },
41
- Type : sql.NullString {String : string (auth .LocalAuth ), Valid : true },
40
+ Type : sql.NullString {String : string (user .LocalAuth ), Valid : true },
42
41
}
43
42
token_data , err := token_model .Get ()
44
43
if err != nil {
@@ -80,8 +79,8 @@ func (m *MockAuthService) Callback(c *fiber.Ctx) (string, error) {
80
79
return "" , nil
81
80
}
82
81
83
- func (a * MockAuthService ) GetUser (auth_user goth.User ) (* user.User , * auth .AuthIdentity , error ) {
84
- return auth .AuthService .GetUser (auth_user )
82
+ func (a * MockAuthService ) GetUser (auth_user goth.User ) (* user.User , * user .AuthIdentity , error ) {
83
+ return user .AuthService .GetUser (auth_user )
85
84
}
86
85
87
86
func (m * MockAuthService ) Register (auth_user goth.User ) (* user.User , error ) {
@@ -103,7 +102,7 @@ func (m *MockAuthService) Register(auth_user goth.User) (*user.User, error) {
103
102
return nil , err
104
103
}
105
104
106
- auth_identity_model := auth .AuthIdentitySQL {
105
+ auth_identity_model := user .AuthIdentitySQL {
107
106
Data : sql.NullString {String : string (data ), Valid : true },
108
107
Type : sql.NullString {String : auth_user .Provider , Valid : true },
109
108
OwnerID : sql.NullString {String : user_data .ID , Valid : true },
@@ -114,14 +113,14 @@ func (m *MockAuthService) Register(auth_user goth.User) (*user.User, error) {
114
113
return user_data , err
115
114
}
116
115
117
- func (a * MockAuthService ) IsAuthenticated (token string ) (* auth .JWTClaim , error ) {
116
+ func (a * MockAuthService ) IsAuthenticated (token string ) (* user .JWTClaim , error ) {
118
117
claims , err := utils .VerifyJWT (token )
119
118
120
119
if err != nil {
121
120
return nil , err
122
121
}
123
122
124
- jwtClaim := new (auth .JWTClaim )
123
+ jwtClaim := new (user .JWTClaim )
125
124
jwtClaim .Pub = claims ["pub" ].(string )
126
125
jwtClaim .Email = claims ["email" ].(string )
127
126
0 commit comments