Skip to content

Commit

Permalink
Added some error-checking on registration
Browse files Browse the repository at this point in the history
  • Loading branch information
c-brooks committed Nov 1, 2016
1 parent 7999da6 commit 4a6c99e
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions app/assets/javascripts/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,12 +484,20 @@ Vue.component('log-reg-btn', {
password_confirmation: self.password_confirmation
},
success: function (data) {
console.log('Success', data);
home.user_id = data.id;
home.user_name = data.name;
window.sessionStorage.setItem( 'user_id', data.id );
window.sessionStorage.setItem( 'user_name', data.name );
home.view = 'empty'
// If any errors, the type of that field will be Object
if (typeof(data.name) !== 'string'
&& typeof(data.email) !== 'string'
&& typeof(data.password) !== 'string'
&& typeof(data.password_confirmation) !== 'string'
) {
// Error logic goes here
} else {
home.user_id = data.id;
home.user_name = data.name;
window.sessionStorage.setItem( 'user_id', data.id );
window.sessionStorage.setItem( 'user_name', data.name );
home.view = 'empty'
}
}
});
}
Expand Down

0 comments on commit 4a6c99e

Please sign in to comment.