|
| 1 | +import * as appModule from "tns-core-modules/application"; |
| 2 | +import { AndroidActivityResultEventData } from "tns-core-modules/application"; |
| 3 | +import lazy from "tns-core-modules/utils/lazy"; |
| 4 | +import { ad as AndroidUtils } from "tns-core-modules/utils/utils"; |
| 5 | +import { ChangePasswordOptions, DataSnapshot, firestore, OnDisconnect as OnDisconnectBase, User } from "./firebase"; |
1 | 6 | import { |
2 | 7 | DocumentSnapshot as DocumentSnapshotBase, |
3 | 8 | FieldValue, |
4 | 9 | firebase, |
5 | 10 | GeoPoint, |
6 | 11 | isDocumentReference |
7 | 12 | } from "./firebase-common"; |
8 | | -import * as firebaseMessaging from "./messaging/messaging"; |
9 | 13 | import * as firebaseFunctions from "./functions/functions"; |
10 | | -import * as appModule from "tns-core-modules/application"; |
11 | | -import { AndroidActivityResultEventData } from "tns-core-modules/application"; |
12 | | -import { ad as AndroidUtils } from "tns-core-modules/utils/utils"; |
13 | | -import lazy from "tns-core-modules/utils/lazy"; |
14 | | -import { firestore, User, OnDisconnect as OnDisconnectBase, DataSnapshot } from "./firebase"; |
| 14 | +import * as firebaseMessaging from "./messaging/messaging"; |
15 | 15 |
|
16 | 16 | declare const com: any; |
17 | 17 | const gmsAds = (<any>com.google.android.gms).ads; |
@@ -1207,29 +1207,25 @@ firebase.resetPassword = arg => { |
1207 | 1207 | }); |
1208 | 1208 | }; |
1209 | 1209 |
|
1210 | | -firebase.changePassword = arg => { |
1211 | | - return new Promise((resolve, reject) => { |
| 1210 | +firebase.changePassword = (arg: ChangePasswordOptions): Promise<void> => { |
| 1211 | + return new Promise<void>((resolve, reject) => { |
1212 | 1212 | try { |
1213 | | - if (!arg.email || !arg.oldPassword || !arg.newPassword) { |
1214 | | - reject("Changing a password requires an email and an oldPassword and a newPassword arguments"); |
1215 | | - } else { |
1216 | | - const onCompleteListener = new gmsTasks.OnCompleteListener({ |
1217 | | - onComplete: task => { |
1218 | | - if (task.isSuccessful()) { |
1219 | | - resolve(); |
1220 | | - } else { |
1221 | | - reject("Updating password failed. " + (task.getException() && task.getException().getReason ? task.getException().getReason() : task.getException())); |
1222 | | - } |
| 1213 | + const onCompleteListener = new gmsTasks.OnCompleteListener({ |
| 1214 | + onComplete: task => { |
| 1215 | + if (task.isSuccessful()) { |
| 1216 | + resolve(); |
| 1217 | + } else { |
| 1218 | + reject("Updating password failed. " + (task.getException() && task.getException().getReason ? task.getException().getReason() : task.getException())); |
1223 | 1219 | } |
1224 | | - }); |
| 1220 | + } |
| 1221 | + }); |
1225 | 1222 |
|
1226 | | - const user = com.google.firebase.auth.FirebaseAuth.getInstance().getCurrentUser(); |
| 1223 | + const user = com.google.firebase.auth.FirebaseAuth.getInstance().getCurrentUser(); |
1227 | 1224 |
|
1228 | | - if (user === null) { |
1229 | | - reject("no current user"); |
1230 | | - } else { |
1231 | | - user.updatePassword(arg.newPassword).addOnCompleteListener(onCompleteListener); |
1232 | | - } |
| 1225 | + if (user === null) { |
| 1226 | + reject("no current user"); |
| 1227 | + } else { |
| 1228 | + user.updatePassword(arg.newPassword).addOnCompleteListener(onCompleteListener); |
1233 | 1229 | } |
1234 | 1230 | } catch (ex) { |
1235 | 1231 | console.log("Error in firebase.changePassword: " + ex); |
|
0 commit comments