Skip to content

Commit

Permalink
European login update (#241)
Browse files Browse the repository at this point in the history
Fix EU auth

Co-authored-by: JACS <[email protected]>
  • Loading branch information
chubby1968 and jacs-zbc authored Apr 7, 2023
1 parent 22c3d8e commit a6717a4
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/controllers/authStrategies/european.brandAuth.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { CookieJar } from 'tough-cookie';
import { EULanguages, EuropeanBrandEnvironment } from '../../constants/europe';
import { AuthStrategy, Code, initSession } from './authStrategy';
import Url, { URLSearchParams } from 'url';
import logger from '../../logger';

const stdHeaders = {
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_1 like Mac OS X) AppleWebKit/604.3.5 (KHTML, like Gecko) Version/11.0 Mobile/15B92 Safari/604.1'
Expand Down Expand Up @@ -56,6 +55,7 @@ export class EuropeanBrandAuthStrategy implements AuthStrategy {
'Content-Type': 'application/x-www-form-urlencoded',
...stdHeaders
},
followRedirect: false,
}));
if(!redirectTo) {
const errorMessage = /<span class="kc-feedback-text">(.+)<\/span>/gm.exec(afterAuthForm);
Expand Down Expand Up @@ -108,19 +108,10 @@ export class EuropeanBrandAuthStrategy implements AuthStrategy {
url = authResult.url;
htmlPage = authResult.body;
}
const { intUserId: appUser } = Url.parse(url, true).query;
if (!appUser) {
logger.warn('@EuropeanBrandAuthStrategy.login: Cannot find the argument userId, please use the following url and connect from a browser.');
logger.warn(this.environment.endpoints.session);
throw new Error(`@EuropeanBrandAuthStrategy.login: Cannot find the argument userId in ${url}.
Please use the following url and connect from a browser, it may probably ask you to "Change your password" or "Accept the new conditions"
Once done, try again.
${this.environment.endpoints.session}`);
}
const { body, statusCode } = await got.post(this.environment.endpoints.silentSignIn, {
cookieJar,
body: {
intUserId: appUser
intUserId: ''
},
json: true,
headers: {
Expand Down

0 comments on commit a6717a4

Please sign in to comment.