@@ -20,7 +20,7 @@ axios.defaults.headers.common['Content-Type'] = 'application/json; charset=utf-8
20
20
axios . defaults . headers . common [ 'Accept' ] = 'application/json'
21
21
axios . defaults . headers . common [ 'X-Requested-With' ] = 'XMLHttpRequest'
22
22
23
- export function createVueAuthStore < UA = unknown > ( storageOptions ?: StorageOptions ) {
23
+ export function createVueAuthStore < UA = unknown > ( storageOptions ?: StorageOptions ) {
24
24
return defineStore (
25
25
'vue-auth' ,
26
26
( ) => {
@@ -36,7 +36,7 @@ export function createVueAuthStore<UA = unknown> (storageOptions?: StorageOption
36
36
* @param options
37
37
* @returns
38
38
*/
39
- const login = async < U = UA , T = LoginCredentials > (
39
+ const login = async < U = UA , T = LoginCredentials > (
40
40
credentials : T ,
41
41
options : AuthOptions < U > = getAuthConfig ( )
42
42
) : Promise < DefinitelyAuthResponse < U > > => {
@@ -53,8 +53,8 @@ export function createVueAuthStore<UA = unknown> (storageOptions?: StorageOption
53
53
token : tkn ,
54
54
message
55
55
} = options . transformResponse
56
- ? options . transformResponse ( data )
57
- : { user : data . user , token : data . token , message : data . message }
56
+ ? options . transformResponse ( data )
57
+ : { user : data . user , token : data . token , message : data . message }
58
58
59
59
user . value = usr
60
60
token . value = tkn
@@ -64,7 +64,11 @@ export function createVueAuthStore<UA = unknown> (storageOptions?: StorageOption
64
64
return { user : usr , token : tkn , message }
65
65
} catch ( error ) {
66
66
const { response } = < ResponseError > error
67
- return { user : { } as U , error : response ?. data ?? error ?? { } , message : response ?. data ?. message }
67
+ return {
68
+ user : { } as U ,
69
+ error : response ?. data ?? error ?? { } ,
70
+ message : response ?. data ?. message
71
+ }
68
72
}
69
73
}
70
74
@@ -75,7 +79,7 @@ export function createVueAuthStore<UA = unknown> (storageOptions?: StorageOption
75
79
* @param options
76
80
* @returns
77
81
*/
78
- const register = async < U = UA , T = RegisterCredentials > (
82
+ const register = async < U = UA , T = RegisterCredentials > (
79
83
credentials : T ,
80
84
options : AuthOptions < U > = getAuthConfig ( )
81
85
) : Promise < DefinitelyAuthResponse < U > > => {
@@ -92,8 +96,8 @@ export function createVueAuthStore<UA = unknown> (storageOptions?: StorageOption
92
96
token : tkn ,
93
97
message
94
98
} = options . transformResponse
95
- ? options . transformResponse ( data )
96
- : { user : data . user , token : data . token , message : data . message }
99
+ ? options . transformResponse ( data )
100
+ : { user : data . user , token : data . token , message : data . message }
97
101
98
102
user . value = usr
99
103
token . value = tkn
@@ -103,7 +107,11 @@ export function createVueAuthStore<UA = unknown> (storageOptions?: StorageOption
103
107
return { user : usr , token : tkn , message }
104
108
} catch ( error ) {
105
109
const { response } = < ResponseError > error
106
- return { user : { } as U , error : response ?. data ?? error ?? { } , message : response ?. data ?. message }
110
+ return {
111
+ user : { } as U ,
112
+ error : response ?. data ?? error ?? { } ,
113
+ message : response ?. data ?. message
114
+ }
107
115
}
108
116
}
109
117
@@ -114,14 +122,14 @@ export function createVueAuthStore<UA = unknown> (storageOptions?: StorageOption
114
122
* @param credentials
115
123
* @returns
116
124
*/
117
- const logout = async < T = unknown > (
125
+ const logout = async < T = unknown > (
118
126
options : AuthOptions = getAuthConfig ( ) ,
119
127
credentials ?: T
120
128
) : Promise <
121
129
| {
122
- error ?: BaseError
123
- message ?: string
124
- }
130
+ error ?: BaseError
131
+ message ?: string
132
+ }
125
133
| undefined
126
134
> => {
127
135
const headers = await buildHeaders ( options , user . value , token . value )
@@ -152,7 +160,7 @@ export function createVueAuthStore<UA = unknown> (storageOptions?: StorageOption
152
160
* @param credentials
153
161
* @returns
154
162
*/
155
- const forgot = async < T = unknown , M extends ForgotResponse = ForgotResponse > (
163
+ const forgot = async < T = unknown , M extends ForgotResponse = ForgotResponse > (
156
164
credentials ?: T ,
157
165
options : AuthOptions = getAuthConfig ( )
158
166
) : Promise < {
@@ -194,7 +202,7 @@ export function createVueAuthStore<UA = unknown> (storageOptions?: StorageOption
194
202
* @param options
195
203
* @returns
196
204
*/
197
- const reset = async < U = UA , T = unknown > (
205
+ const reset = async < U = UA , T = unknown > (
198
206
credentials : T ,
199
207
options : AuthOptions < U > = getAuthConfig ( )
200
208
) : Promise < {
@@ -217,7 +225,11 @@ export function createVueAuthStore<UA = unknown> (storageOptions?: StorageOption
217
225
return { user, message }
218
226
} catch ( error ) {
219
227
const { response } = < ResponseError > error
220
- return { user : { } as U , error : response ?. data ?? error ?? { } , message : response ?. data ?. message }
228
+ return {
229
+ user : { } as U ,
230
+ error : response ?. data ?? error ?? { } ,
231
+ message : response ?. data ?. message
232
+ }
221
233
}
222
234
}
223
235
@@ -229,7 +241,7 @@ export function createVueAuthStore<UA = unknown> (storageOptions?: StorageOption
229
241
* @param credentials
230
242
* @returns
231
243
*/
232
- const loadUserFromStorage = async < U = UA , T = unknown > (
244
+ const loadUserFromStorage = async < U = UA , T = unknown > (
233
245
options : AuthOptions < U > = getAuthConfig ( ) ,
234
246
credentials ?: T ,
235
247
auto ?: boolean
0 commit comments