[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: '',
|
model: '',
|
||||||
timeout: '',
|
timeout: '',
|
||||||
error: '',
|
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: {
|
username: {
|
||||||
|
@ -125,14 +126,17 @@ gs.get.register.func.register = function(){
|
||||||
/* (3) API bindings */
|
/* (3) API bindings */
|
||||||
api.onreceive = function(_response){
|
api.onreceive = function(_response){
|
||||||
|
|
||||||
|
_response = JSON.parse(_response);
|
||||||
|
|
||||||
// manage error
|
// 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');
|
return gs.get.router.push('register');
|
||||||
|
|
||||||
// manage login
|
// manage login
|
||||||
auth.token = _response.token;
|
gstore.set('uid', _response.uid);
|
||||||
document.location = '';
|
auth.token = _response.token;
|
||||||
|
|
||||||
|
document.location = '';
|
||||||
};
|
};
|
||||||
|
|
||||||
api.onclose = function(){ return gs.get.router.push('register'); };
|
api.onclose = function(){ return gs.get.router.push('register'); };
|
||||||
|
|
Loading…
Reference in New Issue