Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor() {
const csrftoken = cookieService.get('csrftoken');
if (!csrftoken) {
const loader = new ProgressiveLoader();
loader.placeLoader('Auth_const');
this.http
.get(ApiRoot() + '/auth/v1/token', {
withCredentials: true,
observe: 'response',
})
.subscribe(res => {
console.log(res);
loader.removeLoader();
// window.location.reload(true);
});
}
}
setSession = authResult => {
// Set the time that the access token will expire at
const expiresAt = JSON.stringify(
authResult.expiresIn * 1000 + new Date().getTime(),
);
localStorage.setItem('access_token', authResult.accessToken);
localStorage.setItem('id_token', authResult.idToken);
localStorage.setItem('expires_at', expiresAt);
const body = new FormData();
const csrftoken = cookieService.get('csrftoken');
// if (csrftoken) {
body.append('access_token', authResult.accessToken);
body.append('csrfmiddlewaretoken', csrftoken);
// const loader = new ProgressiveLoader();
// loader.placeLoader('Auth_ss');
// return this.http
// .post(ApiRoot() + '/auth/v1/signin', body, { withCredentials: true })
// .pipe(
// map(res => {
// loader.removeLoader();
// // console.log(res.json());
// return res;
// }),
// );
// }
};