Guest User

Untitled

a guest
Oct 21st, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. <template>
  2. <div class="window-width row justify-center items-start">
  3. <q-card class="bg-white">
  4. <q-card-media>
  5. <img alt="Quasar logo" src="../assets/DHS-logo.jpg">
  6. </q-card-media>
  7.  
  8. <!--q-card-separator/-->
  9.  
  10. <q-card-title></q-card-title>
  11. <q-card-main>
  12. <form>
  13. <q-field>
  14. <q-input v-model="username" type="text" float-label="User ID" required />
  15. </q-field>
  16. <q-field>
  17. <q-input v-model="password" type="password" float-label="Password" required />
  18. </q-field>
  19. </form>
  20. </q-card-main>
  21.  
  22. <q-card-actions>
  23. <!-- <a href="">Sign In</a> -->
  24. <q-btn class="full-width" color="primary" label="Sign In" @click="login" />
  25. </q-card-actions>
  26. </q-card>
  27. <q-alert color="red" v-if="failedLogin">
  28. Login failed
  29. </q-alert>
  30. </div>
  31. </template>
  32.  
  33. <style>
  34. </style>
  35.  
  36. <script>
  37. import HumanReview from 'human_review';
  38.  
  39. export default {
  40. name: 'Login',
  41.  
  42. data: () => {
  43. return {
  44. username: '',
  45. password: '',
  46. token: '',
  47. failedLogin: false
  48. };
  49. },
  50.  
  51. methods: {
  52. login: function() {
  53. let credentials = new HumanReview.AuthCredentials();
  54. credentials.username = this.username;
  55. credentials.password = this.password;
  56.  
  57. // Access the `$api` client via the `this` object and send the request with a callback.
  58. // The callback needs to be an ES6 arrow function (closure) so that `this` is captured in the scope.
  59. this.$api.userPut(credentials, (error, returnedToken, response) => {
  60. if (error === null) {
  61. // Success
  62. // Tell the Vue Router to redirect to the humanreview page and pass the authentication token
  63. // as a parameter
  64. this.$router.push({ name: 'humanreview', params: { token: returnedToken } });
  65. this.token = returnedToken;
  66. } else {
  67. // Failure - Handle error
  68. this.failedLogin = true;
  69. }
  70. });
  71. }
  72. }
  73. };
  74. </script>
Add Comment
Please, Sign In to add comment