You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
1.9 KiB

5 years ago
4 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <template>
  2. <base-card
  3. :disabled="!valid"
  4. :title="$t('user.login')"
  5. :agree-text="$t('user.login')"
  6. @agree="tryLogin"
  7. >
  8. <template #content>
  9. <v-form v-model="valid">
  10. <v-alert
  11. v-show="showError"
  12. v-model="showError"
  13. type="error"
  14. dismissible
  15. >
  16. {{ $t('errors.invalidUserOrPass') }}
  17. </v-alert>
  18. <v-text-field
  19. v-model="username"
  20. :rules="userNameRules($t('rules.userNameRules'))"
  21. :label="$t('user.username')"
  22. name="username"
  23. :prepend-icon="mdiAccount"
  24. type="text"
  25. autofocus
  26. @keyup.enter="tryLogin"
  27. />
  28. <v-text-field
  29. id="password"
  30. v-model="password"
  31. :rules="passwordRules($t('rules.passwordRules'))"
  32. :label="$t('user.password')"
  33. name="password"
  34. :prepend-icon="mdiLock"
  35. type="password"
  36. @keyup.enter="tryLogin"
  37. />
  38. </v-form>
  39. </template>
  40. </base-card>
  41. </template>
  42. <script lang="ts">
  43. import Vue from 'vue'
  44. import { mdiAccount, mdiLock } from '@mdi/js'
  45. import { userNameRules, passwordRules } from '@/rules/index'
  46. import BaseCard from '@/components/utils/BaseCard.vue'
  47. export default Vue.extend({
  48. components: {
  49. BaseCard
  50. },
  51. props: {
  52. login: {
  53. type: Function,
  54. default: (username: string, password: string) => Promise
  55. }
  56. },
  57. data() {
  58. return {
  59. valid: false,
  60. username: '',
  61. password: '',
  62. userNameRules,
  63. passwordRules,
  64. showError: false,
  65. mdiAccount,
  66. mdiLock
  67. }
  68. },
  69. methods: {
  70. async tryLogin() {
  71. try {
  72. await this.login({
  73. username: this.username,
  74. password: this.password
  75. })
  76. this.$router.push(this.localePath('/projects'))
  77. } catch {
  78. this.showError = true
  79. }
  80. }
  81. }
  82. })
  83. </script>