Login.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <!--
  2. - @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
  3. -
  4. - @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
  5. -
  6. - @license GNU AGPL version 3 or any later version
  7. -
  8. - This program is free software: you can redistribute it and/or modify
  9. - it under the terms of the GNU Affero General Public License as
  10. - published by the Free Software Foundation, either version 3 of the
  11. - License, or (at your option) any later version.
  12. -
  13. - This program is distributed in the hope that it will be useful,
  14. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. - GNU Affero General Public License for more details.
  17. -
  18. - You should have received a copy of the GNU Affero General Public License
  19. - along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. -->
  21. <template>
  22. <div>
  23. <transition name="fade" mode="out-in">
  24. <div v-if="!resetPassword && resetPasswordTarget === ''"
  25. key="login">
  26. <LoginForm
  27. :username.sync="user"
  28. :redirect-url="redirectUrl"
  29. :direct-login="directLogin"
  30. :messages="messages"
  31. :errors="errors"
  32. :throttle-delay="throttleDelay"
  33. :inverted-colors="invertedColors"
  34. :auto-complete-allowed="autoCompleteAllowed"
  35. @submit="loading = true" />
  36. <a v-if="canResetPassword && resetPasswordLink !== ''"
  37. id="lost-password"
  38. :href="resetPasswordLink">
  39. {{ t('core', 'Forgot password?') }}
  40. </a>
  41. <a v-else-if="canResetPassword && !resetPassword"
  42. id="lost-password"
  43. :href="resetPasswordLink"
  44. @click.prevent="resetPassword = true">
  45. {{ t('core', 'Forgot password?') }}
  46. </a>
  47. </div>
  48. <div v-else-if="!loading && canResetPassword"
  49. key="reset"
  50. class="login-additional">
  51. <div class="lost-password-container">
  52. <ResetPassword v-if="resetPassword"
  53. :username.sync="user"
  54. :reset-password-link="resetPasswordLink"
  55. :inverted-colors="invertedColors"
  56. @abort="resetPassword = false" />
  57. </div>
  58. </div>
  59. <div v-else-if="resetPasswordTarget !== ''">
  60. <UpdatePassword :username.sync="user"
  61. :reset-password-target="resetPasswordTarget"
  62. :inverted-colors="invertedColors"
  63. @done="passwordResetFinished" />
  64. </div>
  65. </transition>
  66. </div>
  67. </template>
  68. <script>
  69. import LoginForm from '../components/login/LoginForm.vue'
  70. import ResetPassword from '../components/login/ResetPassword.vue'
  71. import UpdatePassword from '../components/login/UpdatePassword.vue'
  72. export default {
  73. name: 'Login',
  74. components: {
  75. LoginForm,
  76. ResetPassword,
  77. UpdatePassword
  78. },
  79. props: {
  80. username: {
  81. type: String,
  82. default: ''
  83. },
  84. redirectUrl: {
  85. type: String
  86. },
  87. errors: {
  88. type: Array,
  89. default: () => []
  90. },
  91. messages: {
  92. type: Array,
  93. default: () => []
  94. },
  95. throttleDelay: {
  96. type: Number
  97. },
  98. canResetPassword: {
  99. type: Boolean,
  100. default: false
  101. },
  102. resetPasswordLink: {
  103. type: String
  104. },
  105. resetPasswordTarget: {
  106. type: String
  107. },
  108. invertedColors: {
  109. type: Boolean,
  110. default: false
  111. },
  112. autoCompleteAllowed: {
  113. type: Boolean,
  114. default: true
  115. },
  116. directLogin: {
  117. type: Boolean,
  118. default: false
  119. }
  120. },
  121. data() {
  122. return {
  123. loading: false,
  124. user: this.username,
  125. resetPassword: false
  126. }
  127. },
  128. methods: {
  129. passwordResetFinished() {
  130. this.resetPasswordTarget = ''
  131. }
  132. }
  133. }
  134. </script>
  135. <style>
  136. .fade-enter-active, .fade-leave-active {
  137. transition: opacity .3s;
  138. }
  139. .fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
  140. opacity: 0;
  141. }
  142. </style>