Skip to content

Commit 3a91ce4

Browse files
committed
refactor(mon-pix): use session helper in campaings join
1 parent 9cebcb3 commit 3a91ce4

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

mon-pix/app/components/routes/campaigns/join/associate-sco-student-with-mediacentre-form.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default class AssociateScoStudentWithMediacentreForm extends Component {
2323
constructor() {
2424
super(...arguments);
2525

26-
const tokenIdForExternalUser = this.session.data.externalUser;
26+
const tokenIdForExternalUser = this.session.externalUserTokenFromGar;
2727
if (tokenIdForExternalUser) {
2828
const userFirstNameAndLastName = decodeToken(tokenIdForExternalUser);
2929
this.firstName = userFirstNameAndLastName['first_name'];
@@ -53,7 +53,7 @@ export default class AssociateScoStudentWithMediacentreForm extends Component {
5353
}
5454

5555
_createExternalUserRecord() {
56-
const externalUserToken = this.session.get('data.externalUser');
56+
const externalUserToken = this.session.externalUserTokenFromGar;
5757
return this.store.createRecord('external-user', {
5858
birthdate: this.attributes.birthdate,
5959
campaignCode: this.args.campaignCode,
@@ -70,7 +70,7 @@ export default class AssociateScoStudentWithMediacentreForm extends Component {
7070
} else {
7171
this.reconciliationError = error;
7272
this.displayInformationModal = true;
73-
this.session.set('data.expectedUserId', error.meta.userId);
73+
this.session.expectedUserIdFromGar = error.meta.userId;
7474
}
7575
} else if (error.status === '404') {
7676
this.errorMessage = this.intl.t('pages.join.sco.error-not-found', { htmlSafe: true });

mon-pix/app/controllers/campaigns/join/sco-mediacentre.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default class ScoMediacentreController extends Controller {
1111
async createAndReconcile(externalUser) {
1212
const response = await externalUser.save();
1313

14-
this.session.set('data.externalUser', null);
14+
this.session.revokeGarAuthenticationContext();
1515

1616
await this.session.authenticate('authenticator:oauth2', { token: response.accessToken });
1717
await this.currentUser.load();

mon-pix/app/controllers/campaigns/join/student-sco.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default class StudentScoController extends Controller {
2222

2323
await this.session.authenticate('authenticator:oauth2', { token: externalUserAuthenticationRequest.accessToken });
2424

25-
await this._clearExternalUserContext();
25+
this.session.revokeGarAuthenticationContext();
2626

2727
await this.currentUser.load();
2828
await this._reconcileUser();
@@ -38,9 +38,4 @@ export default class StudentScoController extends Controller {
3838
})
3939
.save({ adapterOptions: { tryReconciliation: true } });
4040
}
41-
42-
_clearExternalUserContext() {
43-
this.session.set('data.externalUser', null);
44-
this.session.set('data.expectedUserId', null);
45-
}
4641
}

0 commit comments

Comments
 (0)