This repository was archived by the owner on Apr 4, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +72
-1
lines changed Expand file tree Collapse file tree 4 files changed +72
-1
lines changed Original file line number Diff line number Diff line change @@ -174,6 +174,29 @@ You can expect more login mechanisms to be added in the future.
174174 )
175175```
176176
177+ #### Creating an Password account
178+ ``` js
179+ firebase .createUser ({
180+ 181+ password: ' firebase'
182+ }).then (
183+ function (uid ) {
184+ dialogs .alert ({
185+ title: " User created" ,
186+ message: " uid: " + uid,
187+ okButtonText: " Nice!"
188+ })
189+ },
190+ function (errorMessage ) {
191+ dialogs .alert ({
192+ title: " No user created" ,
193+ message: errorMessage,
194+ okButtonText: " OK, got it"
195+ })
196+ }
197+ )
198+ ```
199+
177200### logout
178201Shouldn't be more complicated than:
179202
Original file line number Diff line number Diff line change @@ -135,6 +135,31 @@ firebase.login = function (arg) {
135135 } ) ;
136136} ;
137137
138+ firebase . createUser = function ( arg ) {
139+ return new Promise ( function ( resolve , reject ) {
140+ try {
141+ var valueResultHandler = new com . firebase . client . Firebase . ValueResultHandler ( {
142+ onSuccess : function ( authData ) {
143+ console . log ( "--- created: " + authData ) ;
144+ resolve ( firebase . toJsObject ( authData ) . uid ) ;
145+ } ,
146+ onError : function ( firebaseError ) {
147+ reject ( firebaseError . getMessage ( ) ) ;
148+ }
149+ } ) ;
150+
151+ if ( ! arg . email || ! arg . password ) {
152+ reject ( "Creating a user requires an email and password argument" ) ;
153+ } else {
154+ instance . createUser ( arg . email , arg . password , valueResultHandler ) ;
155+ }
156+ } catch ( ex ) {
157+ console . log ( "Error in firebase.createUser: " + ex ) ;
158+ reject ( ex ) ;
159+ }
160+ } ) ;
161+ } ;
162+
138163firebase . addChildEventListener = function ( updateCallback , path ) {
139164 return new Promise ( function ( resolve , reject ) {
140165 try {
Original file line number Diff line number Diff line change @@ -97,6 +97,29 @@ firebase.login = function (arg) {
9797 } ) ;
9898} ;
9999
100+ firebase . createUser = function ( arg ) {
101+ return new Promise ( function ( resolve , reject ) {
102+ try {
103+ var onCompletion = function ( error , authData ) {
104+ if ( error ) {
105+ reject ( error . localizedDescription ) ;
106+ } else {
107+ resolve ( firebase . toJsObject ( authData ) . uid ) ;
108+ }
109+ } ;
110+
111+ if ( ! arg . email || ! arg . password ) {
112+ reject ( "Creating a user requires an email and password argument" ) ;
113+ } else {
114+ instance . createUserPasswordWithValueCompletionBlock ( arg . email , arg . password , onCompletion ) ;
115+ }
116+ } catch ( ex ) {
117+ console . log ( "Error in firebase.createUser: " + ex ) ;
118+ reject ( ex ) ;
119+ }
120+ } ) ;
121+ } ;
122+
100123firebase . addChildEventListener = function ( updateCallback , path ) {
101124 return new Promise ( function ( resolve , reject ) {
102125 try {
Original file line number Diff line number Diff line change 11{
22 "name" : " nativescript-plugin-firebase" ,
3- "version" : " 1.1 .0" ,
3+ "version" : " 1.2 .0" ,
44 "description" : " Fire. Base. Firebase!" ,
55 "main" : " firebase.js" ,
66 "nativescript" : {
You can’t perform that action at this time.
0 commit comments