Skip to content

Commit

Permalink
refactor(mon-pix): replace RSVP uses which have direct native Promise…
Browse files Browse the repository at this point in the history
… equivalents
  • Loading branch information
lego-technix committed Dec 17, 2024
1 parent 022f259 commit fd7d1d8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
5 changes: 2 additions & 3 deletions mon-pix/app/authenticators/anonymous.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import BaseAuthenticator from 'ember-simple-auth/authenticators/base';
import fetch from 'fetch';
import ENV from 'mon-pix/config/environment';
import { decodeToken } from 'mon-pix/helpers/jwt';
import RSVP from 'rsvp';

export default BaseAuthenticator.extend({
intl: service(),
Expand All @@ -31,7 +30,7 @@ export default BaseAuthenticator.extend({

const data = await response.json();
if (!response.ok) {
return RSVP.reject(data);
return Promise.reject(data);
}

const decodedAccessToken = decodeToken(data.access_token);
Expand All @@ -43,7 +42,7 @@ export default BaseAuthenticator.extend({
},

restore(data) {
return new RSVP.Promise((resolve, reject) => {
return new Promise((resolve, reject) => {
if (!isEmpty(data['access_token'])) {
resolve(data);
}
Expand Down
5 changes: 2 additions & 3 deletions mon-pix/app/authenticators/gar.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { isEmpty } from '@ember/utils';
import BaseAuthenticator from 'ember-simple-auth/authenticators/base';
import { decodeToken } from 'mon-pix/helpers/jwt';
import RSVP from 'rsvp';

export default class GarAuthenticator extends BaseAuthenticator {
authenticate(token, tokenDecoder = decodeToken) {
const token_type = 'bearer';
const { user_id, source } = tokenDecoder(token);
return RSVP.resolve({
return Promise.resolve({
token_type,
access_token: token,
user_id,
Expand All @@ -16,7 +15,7 @@ export default class GarAuthenticator extends BaseAuthenticator {
}

restore(data) {
return new RSVP.Promise((resolve, reject) => {
return new Promise((resolve, reject) => {
if (!isEmpty(data['access_token'])) {
resolve(data);
}
Expand Down
3 changes: 1 addition & 2 deletions mon-pix/app/authenticators/oauth2.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import OAuth2PasswordGrant from 'ember-simple-auth/authenticators/oauth2-password-grant';
import ENV from 'mon-pix/config/environment';
import { decodeToken } from 'mon-pix/helpers/jwt';
import RSVP from 'rsvp';

export default class OAuth2 extends OAuth2PasswordGrant {
serverTokenEndpoint = `${ENV.APP.API_HOST}/api/token`;
Expand All @@ -14,7 +13,7 @@ export default class OAuth2 extends OAuth2PasswordGrant {
const decodedAccessToken = decodeToken(token);
const user_id = decodedAccessToken.user_id;
const source = decodedAccessToken.source;
return RSVP.resolve({
return Promise.resolve({
token_type,
access_token: token,
user_id,
Expand Down
5 changes: 2 additions & 3 deletions mon-pix/app/authenticators/oidc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import BaseAuthenticator from 'ember-simple-auth/authenticators/base';
import fetch from 'fetch';
import ENV from 'mon-pix/config/environment';
import { decodeToken } from 'mon-pix/helpers/jwt';
import RSVP from 'rsvp';

export default class OidcAuthenticator extends BaseAuthenticator {
@service intl;
Expand Down Expand Up @@ -49,7 +48,7 @@ export default class OidcAuthenticator extends BaseAuthenticator {

const data = await response.json();
if (!response.ok) {
return RSVP.reject(data);
return Promise.reject(data);
}

const decodedAccessToken = decodeToken(data.access_token);
Expand All @@ -65,7 +64,7 @@ export default class OidcAuthenticator extends BaseAuthenticator {
}

restore(data) {
return new RSVP.Promise((resolve, reject) => {
return new Promise((resolve, reject) => {
if (!isEmpty(data['access_token'])) {
resolve(data);
}
Expand Down

0 comments on commit fd7d1d8

Please sign in to comment.