SHARE
TWEET

Untitled

a guest May 6th, 2017 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { jquery } from 'jquery';
  2. import { getTemplate } from 'templateGenerator';
  3. import * as data from 'data';
  4.  
  5.  
  6. export function login() {
  7.  
  8.     getTemplate('login')
  9.         .then((templateFunc) => {
  10.             //Render template
  11.             let html = templateFunc();
  12.  
  13.             $('#dinamic-container').html(html);
  14.  
  15.             //Login functionality
  16.             $("#btn-login").on("click", (ev) => {
  17.  
  18.                 let user = {
  19.                     email: $("#email").val(),
  20.                     password: $("#password").val(),
  21.                 };
  22.  
  23.                 data.login(user)
  24.  
  25.                 .then((resp) => {
  26.                     localStorage.setItem("email", resp.user.email);
  27.                     localStorage.setItem("authKey", resp.token);
  28.                     $(document.body).addClass("logged-in");
  29.  
  30.                     // router.navigate('/');?????????
  31.                 });
  32.  
  33.                 ev.preventDefault();
  34.                 return false;
  35.             });
  36.         });
  37. }
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