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
33c31a98
Commit
33c31a98
authored
Sep 24, 2019
by
Nabil Sadki
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v1.1.1.0' into v1.1.2.0
parents
a4b8ef91
28d05d0f
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 @
33c31a98
...
@@ -17,7 +17,7 @@ const routes: Routes = [
...
@@ -17,7 +17,7 @@ const routes: Routes = [
loadChildren
:
'./pages/offres/offre-details/offre-details.module#OffreDetailsPageModule'
,
loadChildren
:
'./pages/offres/offre-details/offre-details.module#OffreDetailsPageModule'
,
canActivate
:
[
AuthGuardService
]
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 @
33c31a98
...
@@ -99,8 +99,9 @@ export class AuthService {
...
@@ -99,8 +99,9 @@ export class AuthService {
if
(
this
.
platform
.
is
(
'cordova'
))
{
if
(
this
.
platform
.
is
(
'cordova'
))
{
this
.
httpAdv
.
post
(
Config
.
WORDPRESS_URL
+
'wp-json/jwt-auth/v1/token'
,
authData
,
{}).
then
(
this
.
httpAdv
.
post
(
Config
.
WORDPRESS_URL
+
'wp-json/jwt-auth/v1/token'
,
authData
,
{}).
then
(
res
=>
{
res
=>
{
console
.
log
(
res
);
const
data
=
JSON
.
parse
(
res
.
data
);
this
.
setUser
(
JSON
.
parse
(
res
.
data
));
this
.
setUser
(
data
);
this
.
setUserInfo
(
data
.
token
);
this
.
authState
.
next
(
true
);
this
.
authState
.
next
(
true
);
resolve
(
res
);
resolve
(
res
);
},
},
...
@@ -109,8 +110,42 @@ export class AuthService {
...
@@ -109,8 +110,42 @@ export class AuthService {
}
else
{
}
else
{
this
.
http
.
post
(
Config
.
WORDPRESS_URL
+
'wp-json/jwt-auth/v1/token'
,
authData
).
subscribe
(
this
.
http
.
post
(
Config
.
WORDPRESS_URL
+
'wp-json/jwt-auth/v1/token'
,
authData
).
subscribe
(
res
=>
{
res
=>
{
this
.
setUser
(
res
);
const
data
:
any
=
res
;
this
.
setUser
(
data
);
this
.
setUserInfo
(
data
.
token
);
this
.
authState
.
next
(
true
);
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
);
resolve
(
res
);
},
},
err
=>
reject
(
err
)
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