@@ -2,11 +2,12 @@ const jsonwebtoken = require('jsonwebtoken');
2
2
const { addCompareSnapshotCommand } = require ( 'cypress-visual-regression/dist/command' ) ;
3
3
require ( '@testing-library/cypress/add-commands' ) ;
4
4
5
- function getLoginBody ( username , password ) {
5
+ function getLoginBody ( username , password , scope ) {
6
6
return {
7
7
username,
8
8
password,
9
9
grant_type : 'password' ,
10
+ scope,
10
11
} ;
11
12
}
12
13
@@ -20,7 +21,8 @@ function setEmberSimpleAuthSession(response) {
20
21
access_token : response . body . access_token ,
21
22
user_id : response . body . user_id ,
22
23
refresh_token : response . body . refresh_token ,
23
- expires_in : 1000 ,
24
+ scope : response . body . scope ,
25
+ expires_in : 10000000 ,
24
26
} ,
25
27
} )
26
28
) ;
@@ -32,7 +34,7 @@ Cypress.Commands.add('login', (username, password) => {
32
34
url : `${ Cypress . env ( 'API_URL' ) } /api/token` ,
33
35
method : 'POST' ,
34
36
form : true ,
35
- body : getLoginBody ( username , password ) ,
37
+ body : getLoginBody ( username , password , 'mon-pix' ) ,
36
38
} ) . then ( setEmberSimpleAuthSession ) ;
37
39
cy . wait ( [ '@getCurrentUser' ] ) ;
38
40
} ) ;
@@ -43,7 +45,7 @@ Cypress.Commands.add('loginOrga', (username, password) => {
43
45
url : `${ Cypress . env ( 'API_URL' ) } /api/token` ,
44
46
method : 'POST' ,
45
47
form : true ,
46
- body : getLoginBody ( username , password ) ,
48
+ body : getLoginBody ( username , password , 'pix-orga' ) ,
47
49
} ) . then ( setEmberSimpleAuthSession ) ;
48
50
cy . wait ( [ '@getCurrentUser' ] ) ;
49
51
} ) ;
@@ -54,7 +56,7 @@ Cypress.Commands.add('loginAdmin', (username, password) => {
54
56
url : `${ Cypress . env ( 'API_URL' ) } /api/token` ,
55
57
method : 'POST' ,
56
58
form : true ,
57
- body : getLoginBody ( username , password ) ,
59
+ body : getLoginBody ( username , password , 'pix-admin' ) ,
58
60
} ) . then ( ( response ) => {
59
61
window . localStorage . setItem (
60
62
'ember_simple_auth-session' ,
@@ -63,6 +65,7 @@ Cypress.Commands.add('loginAdmin', (username, password) => {
63
65
authenticator : 'authenticator:oauth2' ,
64
66
token_type : 'bearer' ,
65
67
access_token : response . body . access_token ,
68
+ scope : response . body . scope ,
66
69
user_id : 2 ,
67
70
} ,
68
71
} )
0 commit comments