Skouter mortgage estimates. Web application with view written in PHP and Vue, but controller and models in Go.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

45 lignes
884 B

  1. <template>
  2. <div class="page">
  3. <section class="form inputs">
  4. <h3>Login</h3>
  5. <label>Email</label>
  6. <input v-model="email" required>
  7. <label>Password</label>
  8. <input v-model="password" type="password" required>
  9. <button @click="login">Login</button>
  10. <div class="error"> {{error}} </div>
  11. </section>
  12. </div>
  13. </template>
  14. <script>
  15. function login() {
  16. this.error = ""
  17. return fetch(`/api/login`,
  18. {method: 'POST',
  19. body: JSON.stringify( {email: this.email, password: this.password} ),
  20. }).then(response => {
  21. if (response.ok) {
  22. return response.text()
  23. } else {
  24. this.error = "Invalid credentials"
  25. }
  26. }).then(result => {
  27. if (!result || !result.length) return // Exit if there is no token
  28. this.$emit('login')
  29. window.location.hash = ''
  30. })
  31. }
  32. export default {
  33. emits: [ 'login' ],
  34. methods: { login },
  35. data() {
  36. return { email: "", password: "", error: ""}
  37. },
  38. }
  39. </script>