Advertisement
Guest User

Untitled

a guest
Apr 13th, 2017
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. <i18n>
  2. {
  3. "pl":{
  4. "email": "Adres email",
  5. "password": "Hasło",
  6. "send" : "Wyślij",
  7. "reset": "Resetuj"
  8. },
  9. "en":{
  10. "email": "Email address",
  11. "password": "Password",
  12. "send" : "Send",
  13. "reset": "Reset"
  14. }
  15. }
  16. </i18n>
  17. <template>
  18. <div id="login-wrapper">
  19. <el-row>
  20. <el-col :span="8" :offset="8">
  21. <h1>Bileteria</h1>
  22. <div class="has-error" v-if='errors'>
  23. Logowanie nie powiodło się
  24. </div>
  25. <el-form :model="loginForm">
  26.  
  27. <el-form-item>
  28. <el-input :placeholder="$t('email')" v-model="loginForm.email" autocomplete="off"></el-input>
  29. </el-form-item>
  30.  
  31. <el-form-item>
  32. <el-input :placeholder="$t('password')" type="password" v-model="loginForm.password" autocomplete="off"></el-input>
  33. </el-form-item>
  34.  
  35. <el-form-item>
  36. <el-button type="primary" @click="login()">{{$t('send')}}</el-button>
  37. <el-button @click="resetForm('loginForm')">{{$t('reset')}}</el-button>
  38. </el-form-item>
  39.  
  40. </el-form>
  41.  
  42. </el-col>
  43. </el-row>
  44. </div>
  45. </template>
  46.  
  47. <script>
  48. import {loginUrl, getHeader, apiDomain} from './../config'
  49. import {grantType, clientId, clientSecret} from './../.env'
  50. import Vue from 'vue'
  51. export default {
  52. components: {
  53. },
  54. data () {
  55. return {
  56. loginForm: {
  57. email: '',
  58. password: ''
  59. },
  60. errors: false
  61. }
  62. },
  63. created () {
  64. if (this.userIsLoggedIn()) {
  65. this.$router.push({name: 'dashboard'})
  66. }
  67. },
  68. methods: {
  69. login () {
  70. this.errors = false
  71. const postData = {
  72. grant_type: grantType,
  73. client_id: clientId,
  74. client_secret: clientSecret,
  75. username: this.loginForm.email,
  76. password: this.loginForm.password,
  77. scope: ''
  78. }
  79.  
  80. this.$auth.login(postData).then(function (response) {
  81. // Execute application logic after successful login
  82. this.$router.push({name: 'dashboard'})
  83. })
  84.  
  85. },
  86. userIsLoggedIn () {
  87. return window.localStorage.getItem('authUser')
  88. },
  89. resetForm () {
  90. this.loginForm = {
  91. email: '',
  92. password: ''
  93. };
  94. }
  95. },
  96. computed: {
  97. error () {
  98. console.log(this.errors.body.message)
  99. this.error = this.errors.body.message
  100. }
  101. }
  102. }
  103. </script>
  104.  
  105. <style lang="css" scoped>
  106. #login-wrapper {
  107. height:100%;
  108. display:flex;
  109. justify-content: center;
  110. flex-direction: column;
  111. }
  112.  
  113. h1 {
  114. color: #000;
  115. font-family: "Raleway", sans-serif;
  116. font-weight: 300;
  117. text-align: center;
  118. }
  119.  
  120. .has-error {
  121. color:red;
  122. margin-bottom: 5px;
  123. }
  124. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement