[page.noauth.register] manage registering user with API + JSON parsing in LOGIN/REGISTER

This commit is contained in:
xdrm-brackets 2018-03-27 14:30:04 +02:00
parent d97d339dcf
commit bd9f03235e
1 changed files with 8 additions and 4 deletions

View File

@ -7,7 +7,8 @@ gs.set('register', {
model: '',
timeout: '',
error: '',
validate: (_mail) => /^[\w\.]+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/i.test(_mail)
validate: (_mail) => true
// validate: (_mail) => /^[\w\.]+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/i.test(_mail)
},
username: {
@ -125,14 +126,17 @@ gs.get.register.func.register = function(){
/* (3) API bindings */
api.onreceive = function(_response){
_response = JSON.parse(_response);
// manage error
if( _response.error !== 0 || _response.token == null )
if( _response.error !== 0 || _response.uid == null || _response.token == null )
return gs.get.router.push('register');
// manage login
auth.token = _response.token;
document.location = '';
gstore.set('uid', _response.uid);
auth.token = _response.token;
document.location = '';
};
api.onclose = function(){ return gs.get.router.push('register'); };