client/components/login/login.js
// When a user hits submit, log them in with their name as the username
When a user hits submit, log them in with their name as the username
When a user hits submit log them in with their name as the username
function loginWithoutPassword(t) {
  var firstNameSanitized = $('#first-name').val().toLowerCase().replace(/[^a-zA-Z0-9]/g, '');
  var lastNameSanitized = $('#last-name').val().toLowerCase().replace(/[^a-zA-Z0-9]/g, '');
  var trackSanitized = $('#track-selection').dropdown('get value').toLowerCase().replace(/[^a-zA-Z0-9]/g, '');
  var username = firstNameSanitized + '-' + lastNameSanitized + '-' + trackSanitized;
  var user = {
    username: username,
    password: Meteor.settings.public.password,
    profile: {
      name: $('#first-name').val(),
      track: $('#track-selection').dropdown('get value')
    }
  }
  Meteor.call("createLoginlessAccount",
    user.username,
    user.password,
    user.profile,
    function(error) {
      if (error) {
        console.log("Does user ", user.username, " already exist: ", Boolean(error));
        console.log(error);
      };
      Meteor.loginWithPassword(user.username, user.password, function(error) {
        if (error) {
          console.log("Error logging in user ", user.username);
          console.log(error);
          t.error.set(error.reason);
        }
      });
    });
}
function loginWithoutPassword ( t ) { var firstNameSanitized = $ ( '#first-name' ) . val ( ) . toLowerCase ( ) . replace ( / [^a-zA-Z0-9] / g , '' ) ; var lastNameSanitized = $ ( '#last-name' ) . val ( ) . toLowerCase ( ) . replace ( / [^a-zA-Z0-9] / g , '' ) ; var trackSanitized = $ ( '#track-selection' ) . dropdown ( 'get value' ) . toLowerCase ( ) . replace ( / [^a-zA-Z0-9] / g , '' ) ; var username = firstNameSanitized + '-' + lastNameSanitized + '-' + trackSanitized ; var user = { username : username , password : Meteor . settings . public . password , profile : { name : $ ( '#first-name' ) . val ( ) , track : $ ( '#track-selection' ) . dropdown ( 'get value' ) } } Meteor . call ( "createLoginlessAccount" , user . username , user . password , user . profile , function ( error ) { if ( error ) { console . log ( "Does user " , user . username , " already exist: " , Boolean ( error ) ) ; console . log ( error ) ; } ; Meteor . loginWithPassword ( user . username , user . password , function ( error ) { if ( error ) { console . log ( "Error logging in user " , user . username ) ; console . log ( error ) ; t . error . set ( error . reason ) ; } } ) ; } ) ; }
When a user hits submit, log them in with their name as the username
When a user hits submit log them in with their name as the username
// Auto create username and password // Username is firstname-lastname-track // password is "password". // Removes non-alphanumeric chars. // Try to create a new user // Sign the user in. // If sign in fails, create a new user.