Changeset View
Changeset View
Standalone View
Standalone View
src/resources/vue/PasswordReset.vue
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | <div class="container"> | ||||
<div class="mb-3"> | <div class="mb-3"> | ||||
<label for="reset_password" class="visually-hidden">{{ $t('form.password') }}</label> | <label for="reset_password" class="visually-hidden">{{ $t('form.password') }}</label> | ||||
<input type="password" class="form-control" id="reset_password" :placeholder="$t('form.password')" required v-model="password"> | <input type="password" class="form-control" id="reset_password" :placeholder="$t('form.password')" required v-model="password"> | ||||
</div> | </div> | ||||
<div class="mb-3"> | <div class="mb-3"> | ||||
<label for="reset_confirm" class="visually-hidden">{{ $t('form.password-confirm') }}</label> | <label for="reset_confirm" class="visually-hidden">{{ $t('form.password-confirm') }}</label> | ||||
<input type="password" class="form-control" id="reset_confirm" :placeholder="$t('form.password-confirm')" required v-model="password_confirmation"> | <input type="password" class="form-control" id="reset_confirm" :placeholder="$t('form.password-confirm')" required v-model="password_confirmation"> | ||||
</div> | </div> | ||||
<div class="form-group pt-3"> | |||||
<label for="secondfactor" class="sr-only">2FA</label> | |||||
<div class="input-group"> | |||||
<span class="input-group-prepend"> | |||||
<span class="input-group-text"><svg-icon icon="key"></svg-icon></span> | |||||
</span> | |||||
<input type="text" id="secondfactor" class="form-control rounded-right" placeholder="Second factor code" v-model="secondFactor"> | |||||
</div> | |||||
<small class="form-text text-muted">Second factor code is optional for users with no 2-Factor Authentication setup.</small> | |||||
</div> | |||||
<button class="btn btn-secondary" type="button" @click="stepBack">{{ $t('btn.back') }}</button> | <button class="btn btn-secondary" type="button" @click="stepBack">{{ $t('btn.back') }}</button> | ||||
<button class="btn btn-primary" type="submit"><svg-icon icon="check"></svg-icon> {{ $t('btn.submit') }}</button> | <button class="btn btn-primary" type="submit"><svg-icon icon="check"></svg-icon> {{ $t('btn.submit') }}</button> | ||||
</form> | </form> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</template> | </template> | ||||
<script> | <script> | ||||
export default { | export default { | ||||
data() { | data() { | ||||
return { | return { | ||||
email: '', | email: '', | ||||
code: '', | code: '', | ||||
short_code: '', | short_code: '', | ||||
password: '', | password: '', | ||||
password_confirmation: '', | password_confirmation: '', | ||||
secondFactor: '', | |||||
fromEmail: window.config['mail.from.address'] | fromEmail: window.config['mail.from.address'] | ||||
} | } | ||||
}, | }, | ||||
created() { | created() { | ||||
// Verification code provided, auto-submit Step 2 | // Verification code provided, auto-submit Step 2 | ||||
if (this.$route.params.code) { | if (this.$route.params.code) { | ||||
if (/^([A-Z0-9]+)-([a-zA-Z0-9]+)$/.test(this.$route.params.code)) { | if (/^([A-Z0-9]+)-([a-zA-Z0-9]+)$/.test(this.$route.params.code)) { | ||||
this.short_code = RegExp.$1 | this.short_code = RegExp.$1 | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | export default { | ||||
// Submits the data to the API to reset the password | // Submits the data to the API to reset the password | ||||
submitStep3() { | submitStep3() { | ||||
this.$root.clearFormValidation($('#step3 form')) | this.$root.clearFormValidation($('#step3 form')) | ||||
axios.post('/api/auth/password-reset', { | axios.post('/api/auth/password-reset', { | ||||
code: this.code, | code: this.code, | ||||
short_code: this.short_code, | short_code: this.short_code, | ||||
password: this.password, | password: this.password, | ||||
password_confirmation: this.password_confirmation | password_confirmation: this.password_confirmation, | ||||
secondfactor: this.secondFactor | |||||
}).then(response => { | }).then(response => { | ||||
// auto-login and goto dashboard | // auto-login and goto dashboard | ||||
this.$root.loginUser(response.data) | this.$root.loginUser(response.data) | ||||
}) | }) | ||||
}, | }, | ||||
// Moves the user a step back in registration form | // Moves the user a step back in registration form | ||||
stepBack(e) { | stepBack(e) { | ||||
var card = $(e.target).closest('.card') | var card = $(e.target).closest('.card') | ||||
Show All 18 Lines |