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.

Login.vue 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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="!passwordlessLogin && !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. <br>
  48. <a v-if="hasPasswordless" @click.prevent="passwordlessLogin = true">
  49. {{ t('core', 'Log in with a device') }}
  50. </a>
  51. </div>
  52. <div v-else-if="!loading && passwordlessLogin"
  53. key="reset"
  54. class="login-additional">
  55. <PasswordLessLoginForm
  56. :username.sync="user"
  57. :redirect-url="redirectUrl"
  58. :inverted-colors="invertedColors"
  59. :auto-complete-allowed="autoCompleteAllowed"
  60. :isHttps="isHttps"
  61. :hasPublicKeyCredential="hasPublicKeyCredential"
  62. @submit="loading = true" />
  63. <a @click.prevent="passwordlessLogin = false">
  64. {{ t('core', 'Back') }}
  65. </a>
  66. </div>
  67. <div v-else-if="!loading && canResetPassword"
  68. key="reset"
  69. class="login-additional">
  70. <div class="lost-password-container">
  71. <ResetPassword v-if="resetPassword"
  72. :username.sync="user"
  73. :reset-password-link="resetPasswordLink"
  74. :inverted-colors="invertedColors"
  75. @abort="resetPassword = false" />
  76. </div>
  77. </div>
  78. <div v-else-if="resetPasswordTarget !== ''">
  79. <UpdatePassword :username.sync="user"
  80. :reset-password-target="resetPasswordTarget"
  81. :inverted-colors="invertedColors"
  82. @done="passwordResetFinished" />
  83. </div>
  84. </transition>
  85. </div>
  86. </template>
  87. <script>
  88. import LoginForm from '../components/login/LoginForm.vue'
  89. import PasswordLessLoginForm from '../components/login/PasswordLessLoginForm.vue'
  90. import ResetPassword from '../components/login/ResetPassword.vue'
  91. import UpdatePassword from '../components/login/UpdatePassword.vue'
  92. export default {
  93. name: 'Login',
  94. components: {
  95. LoginForm,
  96. PasswordLessLoginForm,
  97. ResetPassword,
  98. UpdatePassword,
  99. },
  100. props: {
  101. username: {
  102. type: String,
  103. default: '',
  104. },
  105. redirectUrl: {
  106. type: String,
  107. },
  108. errors: {
  109. type: Array,
  110. default: () => [],
  111. },
  112. messages: {
  113. type: Array,
  114. default: () => [],
  115. },
  116. throttleDelay: {
  117. type: Number,
  118. },
  119. canResetPassword: {
  120. type: Boolean,
  121. default: false,
  122. },
  123. resetPasswordLink: {
  124. type: String,
  125. },
  126. resetPasswordTarget: {
  127. type: String,
  128. },
  129. invertedColors: {
  130. type: Boolean,
  131. default: false,
  132. },
  133. autoCompleteAllowed: {
  134. type: Boolean,
  135. default: true,
  136. },
  137. directLogin: {
  138. type: Boolean,
  139. default: false,
  140. },
  141. hasPasswordless: {
  142. type: Boolean,
  143. default: false,
  144. },
  145. isHttps: {
  146. type: Boolean,
  147. default: false,
  148. },
  149. hasPublicKeyCredential: {
  150. type: Boolean,
  151. default: false,
  152. },
  153. },
  154. data() {
  155. return {
  156. loading: false,
  157. user: this.username,
  158. passwordlessLogin: false,
  159. resetPassword: false,
  160. }
  161. },
  162. methods: {
  163. passwordResetFinished() {
  164. this.resetPasswordTarget = ''
  165. this.directLogin = true
  166. },
  167. },
  168. }
  169. </script>
  170. <style>
  171. .fade-enter-active, .fade-leave-active {
  172. transition: opacity .3s;
  173. }
  174. .fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
  175. opacity: 0;
  176. }
  177. </style>