Skouter mortgage estimates. Web application with view written in PHP and Vue, but controller and models in Go.
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.
 
 
 
 
 
 

42 lines
770 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. this.$emit('login')
  23. window.location.hash = ''
  24. } else {
  25. this.error = "Invalid credentials"
  26. }
  27. })
  28. }
  29. export default {
  30. emits: [ 'login' ],
  31. methods: { login },
  32. data() {
  33. return { email: "", password: "", error: ""}
  34. },
  35. }
  36. </script>