Commit f50b3bca27279f9614fd577dc3b4c8c2b7e34872
1 parent
69cb554b
Exists in
master
and in
5 other branches
Fix broken sign up
Showing
1 changed file
with
40 additions
and
50 deletions
Show diff stats
js/main.js
... | ... | @@ -1237,65 +1237,55 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
1237 | 1237 | } |
1238 | 1238 | } else { |
1239 | 1239 | e.preventDefault(); |
1240 | - | |
1241 | 1240 | // show loading |
1242 | 1241 | var $loading = $('.login-container .loading'); |
1243 | 1242 | $loading.show(); |
1244 | - | |
1245 | 1243 | $.ajax({ |
1246 | 1244 | type: 'post', |
1247 | 1245 | url: host + '/api/v1/register', |
1248 | 1246 | data: $signupForm.serialize(), |
1249 | 1247 | }) |
1250 | - .done(handleDone) | |
1251 | - .fail(handleFail) | |
1252 | - .always(handleAlways); | |
1253 | - | |
1254 | - function handleDone(data){ | |
1255 | - $signupForm.hide(); | |
1256 | - $signupForm.removeClass('hide'); | |
1257 | - | |
1258 | - var $sectionContent = $button.closest('.section-content'); | |
1259 | - if($sectionContent && $sectionContent.length > 0){ | |
1260 | - Main.displaySuccess($sectionContent, 'Cadastro efetuado com sucesso', 1000, 'icon-user-created'); | |
1261 | - } | |
1262 | - $(document).trigger('login:success', data); | |
1263 | - } | |
1264 | - | |
1265 | - function handleFail(data, var2) { | |
1266 | - var msg = ""; | |
1267 | - // Reload captcha here | |
1268 | - if(window.lastCaptcha) | |
1269 | - window.lastCaptcha.recarregar(); | |
1270 | - | |
1271 | - if(data.responseJSON){ | |
1272 | - try{ | |
1273 | - msg = Main.responseToText(data.responseJSON.message); | |
1274 | - }catch(ex){ | |
1275 | - var ptBR = {}; | |
1276 | - // (Invalid request) email can't be saved | |
1277 | - ptBR['(Invalid request) email can\'t be saved'] = 'E-mail inválido.'; | |
1278 | - // (Invalid request) login can't be saved | |
1279 | - ptBR['(Invalid request) login can\'t be saved'] = 'Nome de usuário inválido.'; | |
1280 | - ptBR['Please solve the test in order to register.'] = 'Por favor, digite os caracteres da imagem na caixa abaixo dela.'; | |
1281 | - msg = '<br/><br/>'; | |
1282 | - msg += ptBR[data.responseJSON.message] || data.responseJSON.message; | |
1248 | + .done(function (data){ | |
1249 | + $signupForm.hide(); | |
1250 | + $signupForm.removeClass('hide'); | |
1251 | + var $sectionContent = $button.closest('.section-content'); | |
1252 | + if($sectionContent && $sectionContent.length > 0){ | |
1253 | + Main.displaySuccess($sectionContent, 'Cadastro efetuado com sucesso', 1000, 'icon-user-created'); | |
1254 | + } | |
1255 | + $(document).trigger('login:success', data); | |
1256 | + }) | |
1257 | + .fail(function (data, var2) { | |
1258 | + var msg = ""; | |
1259 | + // Reload captcha here | |
1260 | + if(window.lastCaptcha) | |
1261 | + window.lastCaptcha.recarregar(); | |
1262 | + if(data.responseJSON){ | |
1263 | + try{ | |
1264 | + msg = Main.responseToText(data.responseJSON.message); | |
1265 | + }catch(ex){ | |
1266 | + var ptBR = {}; | |
1267 | + // (Invalid request) email can't be saved | |
1268 | + ptBR['(Invalid request) email can\'t be saved'] = 'E-mail inválido.'; | |
1269 | + // (Invalid request) login can't be saved | |
1270 | + ptBR['(Invalid request) login can\'t be saved'] = 'Nome de usuário inválido.'; | |
1271 | + ptBR['Please solve the test in order to register.'] = 'Por favor, digite os caracteres da imagem na caixa abaixo dela.'; | |
1272 | + msg = '<br/><br/>'; | |
1273 | + msg += ptBR[data.responseJSON.message] || data.responseJSON.message; | |
1274 | + } | |
1275 | + }else{ | |
1276 | + msg = '<br/><br/>'; | |
1277 | + msg += 'Erro na comunicação com o servidor.'; | |
1278 | + } | |
1279 | + message.html('<p>Não foi possível efetuar o cadastro:' + msg + '</p>'); | |
1280 | + message.show(); | |
1281 | + $(document).trigger('login:fail', data); | |
1283 | 1282 | } |
1284 | - }else{ | |
1285 | - msg = '<br/><br/>'; | |
1286 | - msg += 'Erro na comunicação com o servidor.'; | |
1287 | - } | |
1288 | - | |
1289 | - message.html('<p>Não foi possível efetuar o cadastro:' + msg + '</p>'); | |
1290 | - message.show(); | |
1291 | - | |
1292 | - $(document).trigger('login:fail', data); | |
1293 | - } | |
1294 | - | |
1295 | - function handleAlways() { | |
1296 | - $loading.hide(); | |
1297 | - $signupForm.show(); | |
1298 | - } | |
1283 | + ) | |
1284 | + .always(function () { | |
1285 | + $loading.hide(); | |
1286 | + $signupForm.show(); | |
1287 | + } | |
1288 | + ); | |
1299 | 1289 | } |
1300 | 1290 | }); |
1301 | 1291 | ... | ... |