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 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <div class="login-page">
  3. <div class="form col-md-12">
  4. <div>
  5. <h4>Login</h4>
  6. </div>
  7. <div v-if="hasError">
  8. <alert :text="errorMessage" :type="'ERROR'" />
  9. </div>
  10. <div class="row">
  11. <div class="col-md-12" style="margin-bottom: 1em">
  12. <div class="input-group mb-3">
  13. <div class="input-group-prepend">
  14. <span class="input-group-text">
  15. <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
  16. </span>
  17. <input
  18. class="form-control"
  19. type="text"
  20. placeholder="Email Address"
  21. v-model="auth.emailAddress"
  22. value
  23. />
  24. </div>
  25. </div>
  26. <div class="input-group mb-3">
  27. <div class="input-group-prepend">
  28. <span class="input-group-text">
  29. <eva-icon name="lock-outline" fill="#24aae1"></eva-icon>
  30. </span>
  31. <input
  32. class="form-control"
  33. :type="isPasswordShown"
  34. v-model="auth.password"
  35. id="password"
  36. placeholder="Password"
  37. value
  38. />
  39. <div class="input-group-append">
  40. <span class="input-group-text" @click="togglePassword()">
  41. <eva-icon v-if="showPassword" name="eye-off-outline" fill="#24aae1"></eva-icon>
  42. <eva-icon v-else name="eye-outline" fill="#24aae1"></eva-icon>
  43. </span>
  44. </div>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. <button @click="Login()" class="btn btn-b-n" type="button">Login</button>
  50. </div>
  51. </div>
  52. </template>
  53. <script>
  54. import { mapState, mapActions } from "vuex";
  55. import alert from "../shared/alert";
  56. export default {
  57. name: "Login",
  58. components: {
  59. alert
  60. },
  61. data() {
  62. return {
  63. isPasswordShown: "password",
  64. showPassword: false,
  65. hasError: false,
  66. errorMessage: ""
  67. };
  68. },
  69. methods: {
  70. ...mapActions("authentiaction", [
  71. "getAuthentication",
  72. "checkAuthentication"
  73. ]),
  74. Login() {
  75. this.checkAuthentication(this.auth).then(() => {
  76. //console.log(JSON.stringify(this.$store.state.authentiaction.result));
  77. // if (this.$store.state.auth.result === "Access Granted") {
  78. // console.log(JSON.stringify(this.$store.state.auth));
  79. // this.$router.push("/");
  80. // } else {
  81. // console.log(JSON.stringify(this.auth));
  82. // this.hasError = true;
  83. // this.errorMessage = this.$store.state.auth.result;
  84. // }
  85. if (this.auth.result === "Access Granted") {
  86. alert("Yes");
  87. } else {
  88. alert("No");
  89. }
  90. });
  91. },
  92. togglePassword() {
  93. if (this.showPassword) {
  94. this.isPasswordShown = "password";
  95. } else {
  96. this.isPasswordShown = "text";
  97. }
  98. this.showPassword = !this.showPassword;
  99. }
  100. },
  101. computed: {
  102. ...mapState("authentiaction", ["auth", "result"])
  103. },
  104. mounted() {
  105. this.getAuthentication();
  106. },
  107. watch: {
  108. auth(value) {
  109. return value;
  110. }
  111. }
  112. };
  113. </script>