react-native-meteor
Advanced tools
Comparing version 1.0.0-rc4 to 1.0.0-rc5
{ | ||
"name": "react-native-meteor", | ||
"version": "1.0.0-rc4", | ||
"version": "1.0.0-rc5", | ||
"description": "Full Meteor Client for React Native", | ||
@@ -5,0 +5,0 @@ "main": "src/Meteor.js", |
@@ -60,3 +60,3 @@ # react-native-meteor [](https://www.npmjs.org/package/react-native-meteor) [](http://badge.fury.io/js/react-native-meteor) [](https://david-dm.org/inProgress-team/react-native-meteor) | ||
}; | ||
}) | ||
}, App) | ||
``` | ||
@@ -221,2 +221,3 @@ | ||
* [Accounts.forgotPassword](http://docs.meteor.com/#/full/accounts_changepassword) | ||
* [Accounts.resetPassword](http://docs.meteor.com/#/full/accounts_resetpassword) | ||
* [Accounts.onLogin](http://docs.meteor.com/#/full/accounts_onlogin) | ||
@@ -250,6 +251,44 @@ * [Accounts.onLoginFailure](http://docs.meteor.com/#/full/accounts_onloginfailure) | ||
* [Github repository](https://github.com/inProgress-team/react-native-meteor-router-flux) | ||
* npm i --save react-native-meteor-router-flux@latest | ||
* [Custom scene renderer](https://github.com/aksonov/react-native-router-flux#switch-new-feature) which allows to select tab scene to show depending from app state. It could be useful for authentication, restricted scenes, etc. | ||
* You can use Switch with createContainer. Example : | ||
```javascript | ||
componentWillMount() { | ||
this.scenes = Actions.create( | ||
<Scene key="root" component={createContainer(this.getMeteorData, Switch)} selector={this.selector} tabs={true}> | ||
<Scene key="loading" hideNavBar={true} component={Loading} /> | ||
<Scene key="login" hideNavBar={true}> | ||
<Scene key="loginbis" component={Login} /> | ||
</Scene> | ||
<Scene key="loggedIn" component={Layout}> | ||
<Scene key="main" hideNavBar={true}> | ||
//... | ||
</Scene> | ||
</Scene> | ||
</Scene> | ||
); | ||
} | ||
getMeteorData() { | ||
return { | ||
connected: Meteor.status().connected, | ||
user: Meteor.user() | ||
} | ||
} | ||
selector(data, props) { | ||
if(!data.connected) { | ||
return "loading"; | ||
} else if (!data.user) { | ||
return "login"; | ||
} else { | ||
return "loggedIn"; | ||
} | ||
} | ||
``` | ||
Note you have to do this sometimes, I have not understood why yet. Please let me know if you find something ;) | ||
```javascript | ||
<Scene key="login" hideNavBar={true}> | ||
<Scene key="loginbis" component={Login} /> | ||
</Scene> | ||
``` | ||
@@ -256,0 +295,0 @@ # Author |
@@ -7,3 +7,3 @@ import React from 'react-native'; | ||
db.debug = false; | ||
db.batchedUpdates = React.addons.batchedUpdates; | ||
db.batchedUpdates = ReactNative.unstable_batchedUpdates; | ||
@@ -10,0 +10,0 @@ export default { |
@@ -49,2 +49,15 @@ import Data from '../Data'; | ||
}, | ||
resetPassword(token, newPassword, callback = ()=>{}) { | ||
if (!newPassword) { | ||
return callback("Must pass a new password"); | ||
} | ||
call("resetPassword", token, hashPassword(newPassword), (err, result) => { | ||
if (!err) { | ||
User._loginWithToken(result.token); | ||
} | ||
callback(err); | ||
}); | ||
}, | ||
onLogin(cb) { | ||
@@ -51,0 +64,0 @@ Data.on('onLogin', cb); |
@@ -5,2 +5,3 @@ import { AsyncStorage } from 'react-native'; | ||
import { hashPassword } from '../../lib/utils'; | ||
import call from '../Call'; | ||
@@ -26,3 +27,3 @@ const TOKEN_KEY = 'reactnativemeteor_usertoken'; | ||
logout(callback) { | ||
this.call("logout", err => { | ||
call("logout", err => { | ||
this.handleLogout(); | ||
@@ -48,3 +49,3 @@ this.connect(); | ||
this._startLoggingIn(); | ||
this.call("login", { | ||
call("login", { | ||
user: selector, | ||
@@ -61,3 +62,3 @@ password: hashPassword(password) | ||
logoutOtherClients(callback = ()=>{}) { | ||
this.call('getNewToken', (err, res) => { | ||
call('getNewToken', (err, res) => { | ||
if(err) return callback(err); | ||
@@ -67,3 +68,3 @@ | ||
this.call('removeOtherTokens', err=>{ | ||
call('removeOtherTokens', err=>{ | ||
callback(err); | ||
@@ -103,2 +104,14 @@ }) | ||
}, | ||
_loginWithToken(value) { | ||
Data._tokenIdSaved = value; | ||
if (value !== null){ | ||
this._startLoggingIn(); | ||
call('login', { resume: value }, (err, result) => { | ||
this._endLoggingIn(); | ||
this._handleLoginCallback(err, result); | ||
}); | ||
} else { | ||
this._endLoggingIn(); | ||
} | ||
}, | ||
async _loadInitialUser() { | ||
@@ -111,12 +124,3 @@ var value = null; | ||
} finally { | ||
Data._tokenIdSaved = value; | ||
if (value !== null){ | ||
this._startLoggingIn(); | ||
this.call('login', { resume: value }, (err, result) => { | ||
this._endLoggingIn(); | ||
this._handleLoginCallback(err, result); | ||
}); | ||
} else { | ||
this._endLoggingIn(); | ||
} | ||
this._loginWithToken(value); | ||
} | ||
@@ -123,0 +127,0 @@ |
55418
1311
302