Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <style scoped lang="stylus">
  2.   .logo {
  3.     width: 80%;
  4.     margin: 0 auto;
  5.   }
  6.  
  7.   a {
  8.     text-decoration: none;
  9.     font-size: 14px;
  10.   }
  11.  
  12.   .loginContainer
  13.     margin: 0 auto
  14. </style>
  15.  
  16. <template>
  17.   <div>
  18.     <v-container>
  19.       <v-layout row>
  20.         <v-flex xs12
  21.                 md6
  22.                 lg4
  23.                 xl3
  24.                 class="loginContainer">
  25.           <div class="text-xs-center mt-5 mb-5">
  26.             <img class="logo"
  27.                  src="/images/pg-logo.png">
  28.           </div>
  29.           <form v-on:submit.prevent="login()">
  30.             <v-text-field name="username"
  31.                           label="Username"
  32.                           v-model="username"
  33.                           id="username"
  34.                           v-validate="'required|email'"
  35.                           :data-vv-delay="vRules.delayFor('username')"
  36.                           :errors="vErrors.errorsFor('username')">
  37.             </v-text-field>
  38.             <v-text-field name="password"
  39.                           label="Password"
  40.                           v-model="password"
  41.                           id="password"
  42.                           :append-icon="hidden ? 'visibility' : 'visibility_off'"
  43.                           :append-icon-cb="() => (hidden = !hidden)"
  44.                           :type="hidden ? 'password' : 'text'"
  45.                           v-validate="'required'">
  46.             </v-text-field>
  47.             <v-btn default
  48.                    block
  49.                    type="submit"
  50.                    class="primary ma-0 mb-4">Sign In
  51.             </v-btn>
  52.             <div class="text-xs-center">
  53.               <a href=""> Forgot Password?</a>
  54.             </div>
  55.           </form>
  56.         </v-flex>
  57.       </v-layout>
  58.  
  59.     </v-container>
  60.   </div>
  61. </template>
  62.  
  63. <script>
  64.   import Vue from 'vue'
  65.   import VeeValidate from 'vee-validate'
  66.  
  67.   const config = {
  68.     errorBagName: 'vvErrors'
  69.   }
  70.  
  71.   Vue.use(VeeValidate, config)
  72.  
  73.   export default {
  74.     computed: {
  75.       vRules() {
  76.         const rules = {
  77.           fields: this.fields,
  78.           delayFor(field) {
  79.             const f = this.fields[field]
  80.             return f && f.validated ? 0 : 2000
  81.           },
  82.           validateOnFor(field) {
  83.             const f = this.fields[field]
  84.             return f && f.validated ? 'blur|keyup' : 'blur'
  85.           }
  86.         }
  87.  
  88.         return rules
  89.       },
  90.       vErrors() {
  91.         this.vvErrors.errorsFor = function (field) { // eslint-disable-line
  92.           return this.collect(field).length ? this.collect(field) : ''
  93.         }
  94.         return this.vvErrors
  95.       }
  96.     },
  97.     data() {
  98.       return {
  99.         hidden: true,
  100.         password: '',
  101.         username: '',
  102.         login() {
  103.           if (this.username === 'admin' && this.password === 'admin') {
  104.             this.$nuxt.$router.replace({ path: '/users' })
  105.           }
  106.         }
  107.       }
  108.     }
  109.   }
  110. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement