This commit is contained in:
Filipe Pinho 2019-03-13 00:55:48 +00:00
commit ffa5f3ec14
6 changed files with 54 additions and 11 deletions

View File

@ -135,6 +135,7 @@ class App extends Component {
//faz call //faz call
_reset=()=>{ _reset=()=>{
//fecha modal //fecha modal
this.props.resetPassword(this.props.userDetails.token,this.state.resetText),
this.setState({modalResetPassword:false}) this.setState({modalResetPassword:false})
//faz call //faz call
} }
@ -193,12 +194,12 @@ class App extends Component {
/> />
</View> </View>
</Modal> </Modal>
<Modal <Modal
isVisible={this.state.modalResetPassword} isVisible={this.state.modalResetPassword}
onBackdropPress={this._toggle} onBackdropPress={this._toggle}
onBackButtonPress={this._toggle} onBackButtonPress={this._toggle}
animationInTiming={1500} animationInTiming={1100}
animationOutTiming={1500} animationOutTiming={1100}
> >
<View style={{ backgroundColor: "white" , padding:20,paddingBottom:0, alignItems:'center'}}> <View style={{ backgroundColor: "white" , padding:20,paddingBottom:0, alignItems:'center'}}>
<View> <View>
@ -207,15 +208,15 @@ class App extends Component {
<TextInput <TextInput
style={styles.resetPassword} style={styles.resetPassword}
onFocus={this._print} onFocus={this._print}
maxLength={10} maxLength={50}
blurOnSubmit={true} blurOnSubmit={true}
secureTextEntry={true}
onChangeText={r => this.setState({ resetText })} onChangeText={r => this.setState({ resetText:r })}
clearButtonMode="always" clearButtonMode="always"
value={this.state.resetText} value={this.state.resetText}
clearTextOnFocus={true} clearTextOnFocus={true}
onSubmitEditing={Keyboard.dismiss} onSubmitEditing={Keyboard.dismiss}
placeholder="geral@enei.pt" placeholder="Email ou Qr code"
/> />
<Button <Button
@ -233,7 +234,8 @@ class App extends Component {
width: "100%", width: "100%",
justifyContent: "center", justifyContent: "center",
alignItems: "center" alignItems: "center",
margin:20
}} }}
> >
<Image <Image

View File

@ -10,7 +10,7 @@ export const USER_INFO= 'USER_INFO'
export const HOLD='HOLD' export const HOLD='HOLD'
export const GET_EVENTS='GET_EVENTS' export const GET_EVENTS='GET_EVENTS'
export const UPDATE_USER='UPDATE_USER' export const UPDATE_USER='UPDATE_USER'
export const RESET_PASSWORD='RESET_PASSWORD'
//API BLUETREND CALENDÁRIO //API BLUETREND CALENDÁRIO
export const GET_CAREERS='GET_CAREERS' //GET GEST LISTS export const GET_CAREERS='GET_CAREERS' //GET GEST LISTS

View File

@ -22,8 +22,11 @@ import {
OPEN_MODAL, OPEN_MODAL,
LOADINGLOGIN, LOADINGLOGIN,
REMOVE_SESSION, REMOVE_SESSION,
UPDATE_USER UPDATE_USER,
UI_LOGIN_RESET_PASSWORD,
RESET_PASSWORD
} from "./actionTypes"; //Import the actions types constant we defined in our actions } from "./actionTypes"; //Import the actions types constant we defined in our actions
var validator = require("email-validator");
import moment from "moment"; import moment from "moment";
@ -49,6 +52,37 @@ export function waitLogin() {
}; };
} }
export function resetPassword( data){
axios.defaults.baseURL = "http://enei2019.uingress.com/internal/api";
return dispatch=>{
console.log(data)
http://enei2019.uingress.com/internal/api/User/RecoverPassword?input=TNQHZ3DQMM&type=1
var inputType=1;
if( validator.validate(data))
inputType=0
axios.get(`/User/RecoverPassword?input=${data}&type=${inputType}`).then(p=>{
Alert.alert("Sucesso!","O pedido de recuperação de password foi enviado para o email." )
}).catch(err=>{
if(inputType==1){
Alert.alert("Erro!", "O QR code intruzido não é válido.")
}
else{
Alert.alert("Erro!", "O email introduzido não é válido.")
}
s
})
dispatch({
type:RESET_PASSWORD
})
}
}
export function changePassword(token, old, new1, new2) { export function changePassword(token, old, new1, new2) {
axios.defaults.headers.common = { axios.defaults.headers.common = {
Authorization: `bearer ${token.access_token}` Authorization: `bearer ${token.access_token}`

View File

@ -18,7 +18,8 @@ export {checkUser,
loginInternal, loginInternal,
waitLogin, waitLogin,
removeSession, removeSession,
changePassword changePassword,
resetPassword
} from "./api" } from "./api"

5
App/package-lock.json generated
View File

@ -2745,6 +2745,11 @@
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
}, },
"email-validator": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/email-validator/-/email-validator-2.0.4.tgz",
"integrity": "sha512-gYCwo7kh5S3IDyZPLZf6hSS0MnZT8QmJFqYvbqlDZSbwdZlY6QZWxJ4i/6UhITOJ4XzyI647Bm2MXKCLqnJ4nQ=="
},
"emojis-list": { "emojis-list": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz",

View File

@ -9,6 +9,7 @@
"dependencies": { "dependencies": {
"@redux-offline/redux-offline": "^2.5.1", "@redux-offline/redux-offline": "^2.5.1",
"axios": "^0.18.0", "axios": "^0.18.0",
"email-validator": "^2.0.4",
"expo": "^32.0.5", "expo": "^32.0.5",
"material-icons-react": "^1.0.4", "material-icons-react": "^1.0.4",
"moment": "^2.24.0", "moment": "^2.24.0",