Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,20 @@ server.signInWithEmail('[email protected]', '123456')
})
```

#### signInWithCustomToken()

To sign a user using a self-signed custom token, use the `signInWithCustomToken()` function. It accepts one parameter, the custom token:

```javascript
server.signInWithCustomToken(TOKEN)
.then((user) => {
console.log('User successfully logged in', user)
})
.catch((err) => {
console.error('User signin error', err);
})
```

#### signInWithProvider()

We can use an external authentication provider, such as twitter/facebook for authentication. In order to use an external provider, we need to include another library to handle authentication.
Expand Down
9 changes: 9 additions & 0 deletions firestack.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ export default class Firestack {
return promisify('signInWithProvider')(provider, authToken, authSecret);
}

/**
* Sign the user in with a custom auth token
* @param {string} customToken A self-signed custom auth token.
* @return {Promise} A promise resolved upon completion
*/
signInWithCustomToken(customToken) {
return promisify('signInWithCustomToken')(customToken);
}

/**
* Reauthenticate a user with a third-party authentication provider
* @param {string} provider The provider name
Expand Down
21 changes: 21 additions & 0 deletions ios/Firestack/Firestack.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,27 @@ @implementation Firestack
}
}

RCT_EXPORT_METHOD(signInWithCustomToken:
(NSString *)customToken
callback:(RCTResponseSenderBlock) callback)
{
[[FIRAuth auth]
signInWithCustomToken:customToken
completion:^(FIRUser *user, NSError *error) {

if (user != nil) {
NSDictionary *userProps = [self userPropsFromFIRUser:user];
callback(@[[NSNull null], userProps]);
} else {
NSDictionary *err =
[self handleFirebaseError:@"signinError"
error:error
withUser:user];
callback(@[err]);
}
}];
}

RCT_EXPORT_METHOD(signInWithProvider:
(NSString *)provider
token:(NSString *)authToken
Expand Down