Guest User

Untitled

a guest
Mar 25th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import {Injectable} from 'angular2/core';
  2. import {Http} from 'angular2/http';
  3. import 'rxjs/Rx';
  4. import {Storage, LocalStorage, Events} from 'ionic-angular';
  5.  
  6. const SERVER_URL = 'http://mindlydk.ps3.dev.infoproducts.dk';
  7.  
  8. @Injectable()
  9. export class UserData {
  10.  
  11.     constructor(private http: Http, private events: Events) {
  12.     }
  13.  
  14.     login(email, password) {
  15.         var postData = JSON.stringify({
  16.             email: email,
  17.             password: password
  18.         });
  19.         return this.http.post(SERVER_URL + '/api/login.json', postData)
  20.             .toPromise()
  21.             .then(response => {
  22.                 return response.json();
  23.             }, this.handleError);
  24.     }
  25.  
  26.     logout() {
  27.         this.events.publish('user:logout');
  28.     }
  29.  
  30.     resetPassword(email) {
  31.  
  32.     }
  33.  
  34.     isLoggedIn() {
  35.  
  36.     }
  37.  
  38.     handleError(error) {
  39.         console.log(error);
  40.         return error.json().message || 'Server error, please try again later';
  41.     }
  42.  
  43. }
Add Comment
Please, Sign In to add comment