This commit is contained in:
Moriz Wahl 2021-04-20 20:43:09 +02:00
parent 1023e8932a
commit 4862faf339
2 changed files with 66 additions and 69 deletions

View File

@ -73,21 +73,19 @@ const loginAPI = {
},
loginViaEmailVerificationCode: async (optin) => {
return apiGet(
CONFIG.LOGIN_API_URL
+ 'loginViaEmailVerificationCode?emailVerificationCode='
+ optin
CONFIG.LOGIN_API_URL + 'loginViaEmailVerificationCode?emailVerificationCode=' + optin,
)
},
changePassword: async (session_id, email, password) => {
const payload = {
session_id,
email,
'update': {
update: {
'User.password': password,
},
}
return apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload)
}
return apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload)
},
}
export default loginAPI

View File

@ -91,68 +91,67 @@
</div>
</template>
<script>
import loginAPI from '../../apis/loginAPI'
export default {
name: 'reset',
data() {
return {
rules: [
{ message: this.$t('site.signup.lowercase'), regex: /[a-z]+/ },
{ message: this.$t('site.signup.uppercase'), regex: /[A-Z]+/ },
{ message: this.$t('site.signup.minimum'), regex: /.{8,}/ },
{ message: this.$t('site.signup.one_number'), regex: /[0-9]+/ },
],
password: '',
checkPassword: '',
passwordVisible: false,
submitted: false,
authenticated: false,
session_id: null,
}
},
methods: {
togglePasswordVisibility() {
this.passwordVisible = !this.passwordVisible
},
onSubmit() {
this.$store.dispatch('createUser', {
password: this.model.password,
})
this.model.password = ''
this.$router.push('/thx')
},
},
computed: {
samePasswords() {
return this.password === this.checkPassword
},
passwordsFilled() {
return this.password !== '' && this.checkPassword !== ''
},
passwordValidation() {
let errors = []
for (let condition of this.rules) {
if (!condition.regex.test(this.password)) {
errors.push(condition.message)
}
}
if (errors.length === 0) {
return { valid: true, errors }
}
return { valid: false, errors }
},
},
async created() {
const optin = this.$route.params.optin
const result = await loginAPI.loginViaEmailVerificationCode(optin)
console.log('result', result)
if (result.success) {
this.authenticated = true
this.session_id = result.result.data.session_id
} else {
alert(result.result.message)
}
},
}
import loginAPI from '../../apis/loginAPI'
export default {
name: 'reset',
data() {
return {
rules: [
{ message: this.$t('site.signup.lowercase'), regex: /[a-z]+/ },
{ message: this.$t('site.signup.uppercase'), regex: /[A-Z]+/ },
{ message: this.$t('site.signup.minimum'), regex: /.{8,}/ },
{ message: this.$t('site.signup.one_number'), regex: /[0-9]+/ },
],
password: '',
checkPassword: '',
passwordVisible: false,
submitted: false,
authenticated: false,
session_id: null,
}
},
methods: {
togglePasswordVisibility() {
this.passwordVisible = !this.passwordVisible
},
onSubmit() {
this.$store.dispatch('createUser', {
password: this.model.password,
})
this.model.password = ''
this.$router.push('/thx')
},
},
computed: {
samePasswords() {
return this.password === this.checkPassword
},
passwordsFilled() {
return this.password !== '' && this.checkPassword !== ''
},
passwordValidation() {
let errors = []
for (let condition of this.rules) {
if (!condition.regex.test(this.password)) {
errors.push(condition.message)
}
}
if (errors.length === 0) {
return { valid: true, errors }
}
return { valid: false, errors }
},
},
async created() {
const optin = this.$route.params.optin
const result = await loginAPI.loginViaEmailVerificationCode(optin)
if (result.success) {
this.authenticated = true
this.session_id = result.result.data.session_id
} else {
alert(result.result.message)
}
},
}
</script>
<style></style>