Skip to content

Commit

Permalink
Step 7.8: Added phone service
Browse files Browse the repository at this point in the history
  • Loading branch information
DAB0mB authored and darkbasic committed Oct 16, 2017
1 parent 2e24939 commit ccbc12e
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/services/phone.ts
@@ -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.