2016-03-19 16:58:27 +08:00
|
|
|
///<reference path="../../browser.d.ts"/>
|
|
|
|
|
|
|
|
import {Injectable} from 'angular2/core';
|
|
|
|
import {LoginCredential} from "../../../common/entities/LoginCredential";
|
|
|
|
import {Http} from "angular2/http";
|
|
|
|
import {NetworkService} from "./network.service";
|
2016-03-20 23:54:30 +08:00
|
|
|
import {User} from "../../../common/entities/User";
|
|
|
|
import {Message} from "../../../common/entities/Message";
|
2016-03-19 16:58:27 +08:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class UserService extends NetworkService{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(_http:Http){
|
|
|
|
super(_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-20 23:54:30 +08:00
|
|
|
public login(credential:LoginCredential): Promise<Message<User>>{
|
|
|
|
return this.postJson("/user/login",{"loginCredential": credential});
|
2016-03-19 16:58:27 +08:00
|
|
|
}
|
|
|
|
|
2016-03-21 03:06:14 +08:00
|
|
|
public getSessionUser(): Promise<Message<User>>{
|
|
|
|
return this.getJson("/user/login");
|
|
|
|
}
|
2016-03-19 16:58:27 +08:00
|
|
|
|
|
|
|
}
|