Untitled

By Torrid Guinea Pig, 1 Month ago, written in Plain Text.
URL https://paste.tinyw.in/index.php/view/88837672
Download Paste or View RawExpand paste to full width of browser | Change Viewing Options
  1. <template>
  2. <div class="container" @keyup.enter="login">
  3.   <div class="form-signin text-center">
  4.     <img src="~@/assets/images/logo.png" class="form-signin-heading"/>
  5.     <label for="inputEmail" class="sr-only">Username</label>
  6.     <input v-model="username" type="text" id="username" class="form-control" placeholder="Username" required autofocus>
  7.     <label for="inputPassword" class="sr-only">Password</label>
  8.     <input v-model="password" type="password" id="inputPassword" class="form-control" placeholder="Password" required>
  9.     <div v-if="error != null" class='alert alert-danger'>{{error}}</div>
  10.     <button @click="login" class="btn btn-lg btn-custom btn-block" type="submit">Sign in</button>
  11.   </div>
  12. </div>
  13. <!-- /container -->
  14. </template>
  15. <script>
  16. import auth from '@/api/auth';
  17. import state from '@/state';
  18. import util from '@/util';
  19.  
  20. export default {
  21.   name: 'login-page',
  22.   props: ['noRedirect'],
  23.   created() {
  24.     if (state.getters.loggedIn)
  25.       this.$router.push('/dashboard');
  26.   },
  27.   data() {
  28.     return {
  29.       username: null,
  30.       password: null,
  31.       error: null
  32.     }
  33.   },
  34.   methods: {
  35.     async login() {
  36.       try{
  37.         await state.dispatch('login', {username: this.username, password: this.password});
  38.  
  39.         if(this.noRedirect){
  40.           return;
  41.         }
  42.  
  43.         this.$router.push('/dashboard');
  44.       }catch(e){
  45.         this.error = e.toString();
  46.       }
  47.     }
  48.   },
  49.   watch: {
  50.     async error(value) {
  51.       await util.sleep(3);
  52.       this.error = null;
  53.     }
  54.   }
  55. }
  56. </script>

Reply to "Untitled"

Here you can reply to the paste above

Use TinyW.in

Make Private

Feeling clever? Set some advanced options.