Permalink
Browse files

Step 7.8: Added phone service

  • Loading branch information...
DAB0mB authored and darkbasic committed Jan 27, 2017
1 parent 2e24939 commit ccbc12efffab9192fe162dbba396d335ead11479
Showing with 42 additions and 0 deletions.
  1. +42 −0 src/services/phone.ts
View
@@ -0,0 +1,42 @@
import { Injectable } from '@angular/core';
import { Accounts } from 'meteor/accounts-base';
import { Meteor } from 'meteor/meteor';
@Injectable()
export class PhoneService {
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 ccbc12e

Please sign in to comment.