Skip to content

Instantly share code, notes, and snippets.

View CiscoKidxx's full-sized avatar
🎯
Focusing

Chris Newell CiscoKidxx

🎯
Focusing
View GitHub Profile
login: function (req, res) {
var username = req.param("username");
var password = req.param("password");
Users.findOneByUsername(username).done(function(err, usr){
if(err) {
res.send(500, {error: "DB Error"});
} else {
if (usr) {
var hasher = require("password-hash");
var express = require('express');
var compression = require('compression');
var app = module.exports.prod = exports.prod = express();
var devAPI = 'http://localhost:1337';
var prodAPI = 'http://ninjalist.herokuapp.com';
app.use(compression());
app.use(express.static('dist'));
/**
* Satellizer 0.15.5
* (c) 2016 Sahat Yalkabov
* License: MIT
* Modified by Chris Newell
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
angular.module('app').factory('AuthService', function ($http, $auth, ResponseService, $localStorage, $q, appAuth, userData) {
var factory = {
admin: function (email, password) {
return $http.put('/api/admin/login', {
email: email,
password: password
})
.then(function onSuccess (res){
// Invoking the external __request function
__request.main(urls, function(responses) {
var url, response;
var firstRes = [];
// Looping through each url in the urls array
for (url in responses) {
// reference to the response object
verbose: Could not fetch session, since connecting socket has no cookie (is this a cross-orig
in socket?)
Generated a one-time-use cookie:sails.sid=s%3AFyh1OlLx0fDB0X3F5dR3qzQEI8OzKAaZ.iH45jjpxomPy4v
UN%2BvbV3DX4x7EZew1MM7oXTGgkC24and saved it on the socket handshake.
This will start this socket off with an empty session, i.e. (req.session === {})
That "anonymous" section will only last until the socket is disconnected unless you persist t
he session id in your database,
or by setting the set-cookie response header for an HTTP request that you *know* came from th
e same user (etc)
Alternatively, just make sure the socket sends a `cookie` header or query param when it initi
<!DOCTYPE html>
<html ng-app="app">
<head>
<title>My Index</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.5/united/bootstrap.min.css">
<link rel="stylesheet" href="http://css-spinners.com/css/spinners.css" type="text/css">
<!-- inject:css -->
<!-- endinject -->
angular.module('app').controller('Login', function ($scope, $auth, $location, AuthService) {
$scope.isAuthenticated = $auth.isAuthenticated;
$scope.user = AuthService.currentUser;
console.log(AuthService.currentUser);
$scope.logout = function () {
$auth.logout()
angular.module('app').controller('Signup', function ($scope, $http, toastr, $location, $auth, AuthService) {
$scope.signupForm = {
loading: false
}
$scope.submitSignupForm = function(){
// Set the loading state (i.e. show loading spinner)
$scope.signupForm.loading = true;
angular.module('app').factory('AuthService', function ($http) {
return {
signup: function (email, password, company, name) {
return $http.post('/api/user/email', {email, password, company, name})
},
currentUser: null