Permalink
Browse files

Step 7.8: Added phone service

  • Loading branch information...
DAB0mB authored and darkbasic committed Jan 27, 2017
1 parent 72ff59c commit 0680b8018ca30e49f9f36a3165a7dc12f0880824
Showing with 47 additions and 0 deletions.
  1. +47 −0 src/services/phone.ts
View
@@ -0,0 +1,47 @@
import { Injectable } from '@angular/core';
import { Accounts } from 'meteor/accounts-base';
import { Meteor } from 'meteor/meteor';
import { Platform } from 'ionic-angular';
@Injectable()
export class PhoneService {
constructor(private platform: Platform) {
}
verify(phoneNumber: string): Promise<void> {
return new Promise<void>((resolve, reject) => {
Accounts.requestPhoneVerification(phoneNumber, (e: Error) => {
if (e) {
return reject(e);
}
resolve();
});
});
}
login(phoneNumber: string, code: string): Promise<void> {
return new Promise<void>((resolve, reject) => {
Accounts.verifyPhone(phoneNumber, code, (e: Error) => {
if (e) {
return reject(e);
}
resolve();
});
});
}
logout(): Promise<void> {
return new Promise<void>((resolve, reject) => {
Meteor.logout((e: Error) => {
if (e) {
return reject(e);
}
resolve();
});
});
}
}

0 comments on commit 0680b80

Please sign in to comment.