[page.noauth.register] manage registering user with API + JSON parsing in LOGIN/REGISTER
This commit is contained in:
parent
d97d339dcf
commit
bd9f03235e
|
@ -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'); };
|
||||
|
|
Loading…
Reference in New Issue