Commit 411689e0 authored by zheng liu's avatar zheng liu

Merged in dev (pull request #43)

feat: update
parents 15d6acf8 cf4ad902
......@@ -4,7 +4,7 @@
"license": "GPLv3",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json --preserve-symlinks",
"start": "ng serve --proxy-config proxy.conf.json --preserve-symlinks --port 4202",
"build": "ng build -prod --base-href=/luna/ --deploy '/luna/'",
"test": "ng test",
"lint": "ng lint",
......
......@@ -19,7 +19,7 @@ import {TermPageComponent} from './term-page/term-page.component';
import {ElementServerMenuComponent} from './elements/server-menu/server-menu.component';
const appRoutes: Routes = [
{path: 'users/login', component: LoginComponent},
// {path: 'users/login', component: LoginComponent},
{path: 'rdp/:token', component: RdpPageComponent},
{path: 'term/:token', component: TermPageComponent},
{path: 'replay/:token', component: ReplayPageComponent},
......
......@@ -103,9 +103,9 @@ import {HttpClient, HttpHandler} from '@angular/common/http';
AppService,
HttpService,
LayerService,
NGXLogger,
HttpClient,
HttpHandler
HttpHandler,
NGXLogger
]
})
export class AppModule {
......
......@@ -13,6 +13,7 @@ import {NGXLogger} from 'ngx-logger';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import {DataStore, User, Browser} from './globals';
declare function unescape(s: string): string;
@Injectable()
......@@ -114,7 +115,7 @@ export class AppService implements OnInit {
// this._logger.level = 0;
// }
// this.checklogin();
this.checklogin();
}
ngOnInit() {
......@@ -135,32 +136,43 @@ export class AppService implements OnInit {
// jQuery('angular2').show();
} else {
this.browser();
this._http.get('/api/checklogin')
this._http.get('/api/users/v1/profile/')
.map(res => res.json())
.subscribe(
data => {
User.id = data.id;
User.name = data.name;
User.username = data.username;
User.email = data.email;
User.is_active = data.is_active;
User.is_superuser = data.is_superuser;
User.role = data.role;
// User.groups = data.groups;
User.wechat = data.wechat;
User.comment = data.comment;
User.date_expired = data.date_expired;
User.phone = data.phone.toString();
User.logined = data.logined;
this._logger.debug(User);
},
err => {
this._logger.error(err);
// this._logger.error(err);
User.logined = false;
this._router.navigate(['login']);
window.location.href = document.location.origin + '/users/login?next=' + document.location.pathname;
// this._router.navigate(['login']);
},
() => {
if (User.logined) {
if (document.location.pathname === '/login') {
this._router.navigate(['']);
} else {
this._router.navigate([document.location.pathname]);
}
} else {
this._router.navigate(['login']);
}
// () => {
// if (User.logined) {
// if (document.location.pathname === '/login') {
// this._router.navigate(['']);
// } else {
// this._router.navigate([document.location.pathname]);
// }
// } else {
// this._router.navigate(['login']);
// }
// jQuery('angular2').show();
}
// }
);
}
}
......
......@@ -66,9 +66,13 @@ export let User: {
avatar: string;
role: string;
email: string;
wechat: string;
comment: string;
is_active: boolean;
is_superuser: boolean;
date_joined: string;
last_login: string;
date_expired: string;
groups: Array<Group>;
logined: boolean;
} = {
......@@ -80,9 +84,13 @@ export let User: {
avatar: '',
role: '',
email: '',
wechat: '',
comment: '',
is_active: false,
is_superuser: false,
date_joined: '',
last_login: '',
date_expired: '',
groups: [],
logined: false,
};
......
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