Commit a39ab841 authored by 神楽坂玲奈's avatar 神楽坂玲奈

user

parent f970995f
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { fromPairs } from 'lodash'; import { fromPairs } from 'lodash';
import { User } from './ygopro.service'; import { User } from './ygopro.service';
import * as Raven from 'raven-js';
@Injectable() @Injectable()
export class LoginService { export class LoginService {
user: User; user: User;
token: string; token: string;
...@@ -59,6 +59,11 @@ export class LoginService { ...@@ -59,6 +59,11 @@ export class LoginService {
callback(token: string) { callback(token: string) {
this.token = token; this.token = token;
this.user = <any>fromPairs(Array.from(new URLSearchParams(Buffer.from(token, 'base64').toString()))); this.user = <any>fromPairs(Array.from(new URLSearchParams(Buffer.from(token, 'base64').toString())));
Raven.setUserContext({
email: this.user.email,
id: this.user.external_id,
username: this.user.username
});
localStorage.setItem('login', token); localStorage.setItem('login', token);
if (window.ygopro) { if (window.ygopro) {
try { try {
...@@ -72,5 +77,4 @@ export class LoginService { ...@@ -72,5 +77,4 @@ export class LoginService {
avatar(username: string) { avatar(username: string) {
return 'https://ygobbs.com/user_avatar/ygobbs.com/' + username + '/25/1.png'; return 'https://ygobbs.com/user_avatar/ygobbs.com/' + username + '/25/1.png';
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment