cc: Remove authentication code related to standard environment

This commit is contained in:
Shreya Malviya 2021-09-01 18:01:13 +05:30
parent 8ef07bdca0
commit ffd421bed6
3 changed files with 43 additions and 60 deletions

View File

@ -67,7 +67,6 @@ class AppComponent extends AuthComponent {
loading: true,
completedSteps: completedSteps,
islandMode: undefined,
noAuthLoginAttempted: undefined
};
this.interval = undefined;
this.setMode();
@ -77,8 +76,9 @@ class AppComponent extends AuthComponent {
if (this.state.isLoggedIn === false) {
return
}
this.auth.loggedIn()
.then(res => {
let res = this.auth.loggedIn();
if (this.state.isLoggedIn !== res) {
this.setState({
isLoggedIn: res
@ -113,9 +113,7 @@ class AppComponent extends AuthComponent {
});
}
)
}
});
};
setMode = () => {

View File

@ -48,12 +48,11 @@ class LoginPageComponent extends React.Component {
this.redirectToRegistration()
}
})
this.auth.loggedIn()
.then(res => {
if (res) {
if (this.auth.loggedIn()) {
this.redirectToHome();
}
});
}
render() {

View File

@ -1,8 +1,6 @@
import decode from 'jwt-decode';
export default class AuthService {
NO_AUTH_CREDS = '1234567890!@#$%^&*()_nothing_up_my_sleeve_1234567890!@#$%^&*()';
SECONDS_BEFORE_JWT_EXPIRES = 20;
AUTHENTICATION_API_ENDPOINT = '/api/auth';
REGISTRATION_API_ENDPOINT = '/api/registration';
@ -16,7 +14,7 @@ export default class AuthService {
};
jwtHeader = () => {
if (this._loggedIn()) {
if (this.loggedIn()) {
return 'Bearer ' + this._getToken();
}
};
@ -68,7 +66,7 @@ export default class AuthService {
'Content-Type': 'application/json'
};
if (this._loggedIn()) {
if (this.loggedIn()) {
headers['Authorization'] = 'Bearer ' + this._getToken();
}
@ -101,19 +99,7 @@ export default class AuthService {
})
};
async loggedIn() {
let token = this._getToken();
if ((token === null) || (this._isTokenExpired(token))) {
await this.attemptNoAuthLogin();
}
return this._loggedIn();
}
attemptNoAuthLogin() {
return this._login(this.NO_AUTH_CREDS, this.NO_AUTH_CREDS);
}
_loggedIn() {
loggedIn() {
const token = this._getToken();
return ((token !== null) && !this._isTokenExpired(token));
}