daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest Oct 23rd, 2017 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export default angular.module('ppollitApp.login', [])
  2.       .controller('LoginController', function($scope, $cookies) {
  3.         $scope.myCookieVal = $cookies.get('cookie');
  4.         $scope.setCookie = function(val) {
  5.           $cookies.put('cookie', val);
  6.         };
  7.       })
  8.       .name;
  9.    
  10. 'use strict';
  11.  
  12. export default class LoginController {
  13.   user = {
  14.     name: '',
  15.     email: '',
  16.     password: '',
  17.   };
  18.   errors = {
  19.     login: undefined
  20.   };
  21.   submitted = false;
  22.  
  23.  
  24.   /*@ngInject*/
  25.   constructor(Auth, $state) {
  26.     this.Auth = Auth;
  27.     this.$state = $state;
  28.   }
  29.  
  30.   login(form) {
  31.     this.submitted = true;
  32.  
  33.     if(form.$valid) {
  34.       this.Auth.login({
  35.         email: this.user.email,
  36.         password: this.user.password,
  37.         cookie: this.user.cookie
  38.       })
  39.         .then(() => {
  40.           // Logged in, redirect to home
  41.           this.$state.go('main');
  42.         })
  43.         .catch(err => {
  44.           this.errors.login = err.message;
  45.         });
  46.     }
  47.   }
  48. }
  49.    
  50. <form role="form" class="bottom-75" name="form" ng-submit="vm.login(form)">
  51.             <div class="table-form">
  52.                 <div class="form-groups">
  53.                     <div class="form-group">
  54.                         <input type="text" class="form-control input-lg" id="" placeholder="E-mail" name="email" ng-model="vm.user.email" required>
  55.                     </div>
  56.                     <div class="form-group">
  57.                         <input type="password" class="form-control input-lg" id="" placeholder="Mot de passe" name="mot de passe" ng-model="vm.user.password" required>
  58.                     </div>
  59.  
  60.  
  61.                 </div>
  62.                 <div class="button-container">
  63.                     <button type="submit" class="btn btn-default login"><img src="assets/images/arrow.png" alt=""></button>
  64.                 </div>
  65.  
  66.  
  67.             </div>
  68.             <div class="remember">
  69.                 <label class="checkbox1" for="Option">
  70.                     <input id="Option" type="checkbox" class="">
  71.                     <span></span>
  72.                 </label>
  73.                 Se rappeler de moi
  74.                 <span class="pass"> Mot de passe oublié?</span>
  75.                         <a class="btn btn-primary btn-lg btn-white" ui-sref="signup">Créer un nouveau compte</a>
  76.             </div>
  77.  
  78.  
  79.         <oauth-buttons classes="btn-block"></oauth-buttons>
  80.                   <!--a class="btn btn-lg btn-social-icon btn-twitter btn-white">
  81.                         <span class="fa fa-twitter"></span>
  82.                   </!--a>
  83.  
  84.                     <a class="btn btn-lg btn-social-icon btn-google btn-white">
  85.                         <span class="fa fa-google"></span>
  86.                   </a>
  87.  
  88.                     <a class="btn btn-lg btn-social-icon btn-facebook btn-white" ng-click="OauthButtons.loginOauth('facebook')">
  89.                         <span class="fa fa-facebook"></span>
  90.                   </a-->
  91.             </div>
  92.             </form>
  93.    
  94. 'use strict';
  95.  
  96. import express from 'express';
  97. import mongoose from 'mongoose';
  98. mongoose.Promise = require('bluebird');
  99. import config from './config/environment';
  100. import http from 'http';
  101. import seedDatabaseIfNeeded from './config/seed';
  102.  
  103. // Connect to MongoDB
  104. mongoose.connect(config.mongo.uri, config.mongo.options);
  105. mongoose.connection.on('error', function(err) {
  106.   console.error(`MongoDB connection error: ${err}`);
  107.   process.exit(-1); // eslint-disable-line no-process-exit
  108. });
  109.  
  110. // Setup server
  111. var app = express();
  112. var server = http.createServer(app);
  113. var session = require('express-session');
  114. var cookieParser = require('cookie-parser');
  115. var socketio = require('socket.io')(server, {
  116.   serveClient: config.env !== 'production',
  117.   path: '/socket.io-client'
  118. });
  119.  
  120. require('./config/socketio').default(socketio);
  121. require('./config/express').default(app);
  122. require('./routes').default(app);
  123.  
  124. app.use(cookieParser());
  125.  
  126. app.use(session(
  127.   {
  128.     secret: 'a random string',
  129.     saveUninitialized: false,
  130.     resave: false
  131.   }
  132. ));
  133.  
  134.  
  135. app.get('/cookie', function(req, res) {
  136.   res.cookie(remember, 'cookie_value').send('Cookie is set');
  137. });
  138.  
  139. app.get('/', function(req, res) {
  140.   console.log('Cookies :  ', req.cookies);
  141.   res.cookie(name, 'value', {expire: new Date() + 9999});
  142. });
  143.  
  144. app.get('/clearcookie', function(req, res) {
  145.   clearCookie('cookie_name');
  146.   res.send('Cookie deleted');
  147. });
  148.  
  149.  
  150. var bodyParser = require('body-parser');
  151. /*var fileUpload = require('express-fileupload');
  152. app.use(fileUpload());
  153.  
  154. app.use('/uploads', express.static(__dirname + '/uploads'));
  155.  
  156. // configure the app to use bodyParser()*/
  157. app.use(bodyParser.urlencoded({
  158.     extended: true
  159. }));
  160. app.use(bodyParser.json());
  161.  
  162. // Start server
  163. function startServer() {
  164.   app.angularFullstack = server.listen(config.port, config.ip, function() {
  165.     console.log('Express server listening on %d, in %s mode', config.port, app.get('env'));
  166.   });
  167. }
  168.  
  169. seedDatabaseIfNeeded();
  170. setImmediate(startServer);
  171.  
  172. // Expose app
  173. exports = module.exports = app;
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