mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
Added IValidatable; moved validation to FormData
I still struggle to find out how to deal with arguments like $userNameOrEmail. Should I trim() them in controllers, or in service? If I do it in service, shouldn't all of such validation belong in there?
This commit is contained in:
@ -26,9 +26,9 @@ App.Auth = function(_, jQuery, util, api, appState, promise) {
|
||||
listTags: 'listTags',
|
||||
};
|
||||
|
||||
function loginFromCredentials(userName, password, remember) {
|
||||
function loginFromCredentials(userNameOrEmail, password, remember) {
|
||||
return promise.make(function(resolve, reject) {
|
||||
promise.wait(api.post('/login', {userName: userName, password: password}))
|
||||
promise.wait(api.post('/login', {userNameOrEmail: userNameOrEmail, password: password}))
|
||||
.then(function(response) {
|
||||
updateAppState(response);
|
||||
jQuery.cookie(
|
||||
|
@ -38,11 +38,11 @@ App.Presenters.LoginPresenter = function(
|
||||
e.preventDefault();
|
||||
messagePresenter.hideMessages($messages);
|
||||
|
||||
var userName = $el.find('[name=user]').val();
|
||||
var userNameOrEmail = $el.find('[name=user]').val();
|
||||
var password = $el.find('[name=password]').val();
|
||||
var remember = $el.find('[name=remember]').val();
|
||||
|
||||
if (userName.length === 0) {
|
||||
if (userNameOrEmail.length === 0) {
|
||||
messagePresenter.showError($messages, 'User name cannot be empty.');
|
||||
return false;
|
||||
}
|
||||
@ -52,7 +52,7 @@ App.Presenters.LoginPresenter = function(
|
||||
return false;
|
||||
}
|
||||
|
||||
auth.loginFromCredentials(userName, password, remember)
|
||||
auth.loginFromCredentials(userNameOrEmail, password, remember)
|
||||
.then(function(response) {
|
||||
router.navigateToMainPage();
|
||||
}).fail(function(response) {
|
||||
|
Reference in New Issue
Block a user