I am currently trying to make two event handlers: One for when a user signs up and a new account is made and another for when a user attempts to login. As of this writing, nothing occurs when invalid credentials are implemented and a new user is made, but not getting stored in the database. Can someone explain what the signUp() and auth() methods are doing?
'use strict';
var userService = window.skilly.userService;
const _ = require('lodash');
$(document).ready(function(event) {
$('#signup').on('click', function(event) {
/* stop form from submitting normally */
// event.preventDefault();
/* get some values from elements on the page: */
// var $form = $(this),
// term = $form.find('input[name="s"]').val(),
// url = $form.attr('action');
var user = _.object($("#myForm").serializeArray().map(function (v) {
return [v.name, v.value];
}));
/* Send the data using post */
var signUp = $.ajax({
type: "POST",
url: 'https://skilly-rayman504.c9users.io/user',
success: function(user) {
console.log(user);
}
})
userService.signUp(user);
})
$('#login').on('click', function(event) {
/* stop form from submitting normally */
// event.preventDefault();
/* get some values from elements on the page: */
event.preventDefault();
var creds = _.object($("#form-signin").serializeArray().map(function (v) {
return [v.name, v.value];
}));
$('#btn-close-auth').trigger('click');
// /* Send the data using post */
var auth = $.ajax({
type: "POST",
url: 'https://skilly-rayman504.c9users.io/user/auth',
success: function(user) {
console.log(user);
}
})
userService.auth(creds);
})
})