SHARE
TWEET

Untitled

a guest May 22nd, 2017 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { autoinject, Aurelia } from "aurelia-framework"
  2. import { HttpClient, json } from "aurelia-fetch-client"
  3. import { AuthService } from "aurelia-authentication"
  4. import { Router } from 'aurelia-router';
  5.  
  6. @autoinject
  7. export class login2 {
  8.  
  9.   email = "";
  10.   password = "";
  11.  
  12.    
  13.  
  14.   constructor(private auth: AuthService, private http: HttpClient, message: string, private aurelia: Aurelia, private router : Router) {
  15.      
  16.   }
  17.  
  18.  
  19.   login() {
  20.       var authRequest = {
  21.       username: this.email,
  22.       password: this.password
  23.     };
  24.      
  25.     return this.auth.login(authRequest)
  26.         .then(response => {
  27.             console.log(`Success: ${response}`);
  28.             this.aurelia.setRoot("app");
  29.             this.aurelia.setRoot("app");
  30.  
  31.         })
  32.         .catch(error => {
  33.             console.log(`Error! ${error}`);
  34.             alert("Username / Password is wrong");
  35.         })
  36.   }
  37.    
  38.    
  39.  
  40.  
  41.  
  42.   logout() {
  43.     this.auth.logout('');
  44.   }
  45.  
  46.   redirect() { this.aurelia.setRoot("signup");}
  47.    
  48.  
  49.  
  50. }
  51.  
  52. <template>
  53.  
  54.  
  55.     <div class="container">
  56.       <div class="row vertical-offset-100">
  57.         <div class="col-md-4 col-md-offset-4">
  58.           <div class="panel panel-default">
  59.             <div class="panel-heading">
  60.               <h3 class="panel-title">Please sign in</h3>
  61.             </div>
  62.             <div class="panel-body">
  63.               <form accept-charset="UTF-8" role="form">
  64.                 <fieldset>
  65.                   <div class="form-group">
  66.                     <input class="form-control" placeholder="E-mail" name="email" value.bind="email" type="text">
  67.                   </div>
  68.                   <div class="form-group">
  69.                     <input class="form-control" placeholder="Password" name="password" value.bind="password" type="password" value="">
  70.                   </div>
  71.                   <div class="checkbox">
  72.                     <label>
  73.                       <input name="remember" type="checkbox" value="Remember Me"> Remember Me
  74.                     </label>
  75.                   </div>
  76.                   <input class="btn btn-lg btn-success btn-block" type="submit" click.delegate="login()" value="Login">
  77.                   <input class="btn btn-lg btn-success btn-block" type="submit" click.delegate="redirect()" value="Signup">
  78.                 </fieldset>
  79.               </form>
  80.             </div>
  81.           </div>
  82.         </div>
  83.       </div>
  84.     </div>
  85.  
  86. </template>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top