Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
allo-app
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nabil Sadki
allo-app
Commits
28d05d0f
Commit
28d05d0f
authored
Sep 24, 2019
by
Nabil Sadki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FIX: routing
parent
d5c1aa47
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
4 deletions
+39
-4
app-routing.module.ts
src/app/app-routing.module.ts
+1
-1
auth.service.ts
src/app/services/auth.service.ts
+38
-3
No files found.
src/app/app-routing.module.ts
View file @
28d05d0f
...
...
@@ -17,7 +17,7 @@ const routes: Routes = [
loadChildren
:
'./pages/offres/offre-details/offre-details.module#OffreDetailsPageModule'
,
canActivate
:
[
AuthGuardService
]
},
{
path
:
'login-help'
,
loadChildren
:
'./modals/
compte/
login-help/login-help.module#LoginHelpPageModule'
},
{
path
:
'login-help'
,
loadChildren
:
'./modals/login-help/login-help.module#LoginHelpPageModule'
},
];
...
...
src/app/services/auth.service.ts
View file @
28d05d0f
...
...
@@ -99,8 +99,9 @@ export class AuthService {
if
(
this
.
platform
.
is
(
'cordova'
))
{
this
.
httpAdv
.
post
(
Config
.
WORDPRESS_URL
+
'wp-json/jwt-auth/v1/token'
,
authData
,
{}).
then
(
res
=>
{
console
.
log
(
res
);
this
.
setUser
(
JSON
.
parse
(
res
.
data
));
const
data
=
JSON
.
parse
(
res
.
data
);
this
.
setUser
(
data
);
this
.
setUserInfo
(
data
.
token
);
this
.
authState
.
next
(
true
);
resolve
(
res
);
},
...
...
@@ -109,8 +110,42 @@ export class AuthService {
}
else
{
this
.
http
.
post
(
Config
.
WORDPRESS_URL
+
'wp-json/jwt-auth/v1/token'
,
authData
).
subscribe
(
res
=>
{
this
.
setUser
(
res
);
const
data
:
any
=
res
;
this
.
setUser
(
data
);
this
.
setUserInfo
(
data
.
token
);
this
.
authState
.
next
(
true
);
resolve
(
data
);
},
err
=>
reject
(
err
)
);
}
});
}
setUserInfo
(
token
)
{
return
new
Promise
<
any
>
((
resolve
,
reject
)
=>
{
if
(
this
.
platform
.
is
(
'cordova'
))
{
let
header
:
Headers
=
new
Headers
();
header
.
append
(
'Authorization'
,
'Bearer '
+
token
);
this
.
httpAdv
.
get
(
Config
.
WORDPRESS_URL
+
'wp-json/wp/v2/users/me'
,
{},
{
headers
:
header
}
).
then
(
res
=>
{
console
.
log
(
res
);
resolve
(
res
);
},
err
=>
reject
(
err
)
);
}
else
{
this
.
http
.
get
(
// Config.WORDPRESS_URL + 'wp-json/wp/v2/users/me',
Config
.
WORDPRESS_URL
+
'wp-json/atapi/loggedinuser'
,
{
headers
:
{
Authorization
:
'Bearer '
+
token
}
}
).
subscribe
(
res
=>
{
console
.
log
(
res
);
resolve
(
res
);
},
err
=>
reject
(
err
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment