Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
505d0978
Commit
505d0978
authored
Jan 24, 2016
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove some login code duplication
parent
c88fb8ba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
39 deletions
+27
-39
account.php
qa-include/pages/account.php
+4
-5
login.php
qa-include/pages/login.php
+23
-34
No files found.
qa-include/pages/account.php
View file @
505d0978
...
@@ -210,16 +210,15 @@
...
@@ -210,16 +210,15 @@
else
{
else
{
$errors
=
array
();
$errors
=
array
();
$legacyPassError
=
strtolower
(
qa_db_calc_passcheck
(
$inoldpassword
,
$useraccount
[
'passsalt'
]))
!=
strtolower
(
$useraccount
[
'passcheck'
]);
if
(
QA_PASSWORD_HASH
)
{
if
(
QA_PASSWORD_HASH
)
{
if
(
$passError
=
!
password_verify
(
$inoldpassword
,
$useraccount
[
'passhash'
]);
(
$haspasswordold
&&
(
strtolower
(
qa_db_calc_passcheck
(
$inoldpassword
,
$useraccount
[
'passsalt'
]))
!=
strtolower
(
$useraccount
[
'passcheck'
])))
||
if
((
$haspasswordold
&&
$legacyPassError
)
||
(
!
$haspasswordold
&&
$haspassword
&&
$passError
))
{
(
!
$haspasswordold
&&
$haspassword
&&
!
password_verify
(
$inoldpassword
,
$useraccount
[
'passhash'
]))
)
{
$errors
[
'oldpassword'
]
=
qa_lang
(
'users/password_wrong'
);
$errors
[
'oldpassword'
]
=
qa_lang
(
'users/password_wrong'
);
}
}
}
else
{
}
else
{
if
(
$haspassword
&&
(
strtolower
(
qa_db_calc_passcheck
(
$inoldpassword
,
$useraccount
[
'passsalt'
]))
!=
strtolower
(
$useraccount
[
'passcheck'
]))
)
{
if
(
$haspassword
&&
$legacyPassError
)
{
$errors
[
'oldpassword'
]
=
qa_lang
(
'users/password_wrong'
);
$errors
[
'oldpassword'
]
=
qa_lang
(
'users/password_wrong'
);
}
}
}
}
...
...
qa-include/pages/login.php
View file @
505d0978
...
@@ -68,51 +68,40 @@
...
@@ -68,51 +68,40 @@
$inuserid
=
$matchusers
[
0
];
$inuserid
=
$matchusers
[
0
];
$userinfo
=
qa_db_select_with_pending
(
qa_db_user_account_selectspec
(
$inuserid
,
true
));
$userinfo
=
qa_db_select_with_pending
(
qa_db_user_account_selectspec
(
$inuserid
,
true
));
if
(
QA_PASSWORD_HASH
)
{
$legacyPassOk
=
strtolower
(
qa_db_calc_passcheck
(
$inpassword
,
$userinfo
[
'passsalt'
]))
==
strtolower
(
$userinfo
[
'passcheck'
]);
$haspassword
=
isset
(
$userinfo
[
'passhash'
]);
$haspasswordold
=
isset
(
$userinfo
[
'passsalt'
])
&&
isset
(
$userinfo
[
'passcheck'
]);
if
(
if
(
QA_PASSWORD_HASH
)
{
(
$haspasswordold
&&
strtolower
(
qa_db_calc_passcheck
(
$inpassword
,
$userinfo
[
'passsalt'
]))
==
strtolower
(
$userinfo
[
'passcheck'
]))
||
$haspassword
=
isset
(
$userinfo
[
'passhash'
]);
(
$haspassword
&&
password_verify
(
$inpassword
,
$userinfo
[
'passhash'
]))
$haspasswordold
=
isset
(
$userinfo
[
'passsalt'
])
&&
isset
(
$userinfo
[
'passcheck'
]);
)
{
$passOk
=
password_verify
(
$inpassword
,
$userinfo
[
'passhash'
]);
// login and redirect
require_once
QA_INCLUDE_DIR
.
'app/users.php'
;
if
((
$haspasswordold
&&
$legacyPassOk
)
||
(
$haspassword
&&
$passOk
))
{
// upgrade password or rehash, when options like the cost parameter changed
// upgrade password or rehash, when options like the cost parameter changed
if
(
$haspasswordold
||
password_needs_rehash
(
$userinfo
[
'passhash'
],
PASSWORD_BCRYPT
))
{
if
(
$haspasswordold
||
password_needs_rehash
(
$userinfo
[
'passhash'
],
PASSWORD_BCRYPT
))
{
qa_db_user_set_password
(
$inuserid
,
$inpassword
);
qa_db_user_set_password
(
$inuserid
,
$inpassword
);
}
}
qa_set_logged_in_user
(
$inuserid
,
$userinfo
[
'handle'
],
!
empty
(
$inremember
));
}
else
{
$topath
=
qa_get
(
'to'
);
if
(
isset
(
$topath
))
qa_redirect_raw
(
qa_path_to_root
()
.
$topath
);
// path already provided as URL fragment
elseif
(
$passwordsent
)
qa_redirect
(
'account'
);
else
qa_redirect
(
''
);
}
else
$errors
[
'password'
]
=
qa_lang
(
'users/password_wrong'
);
$errors
[
'password'
]
=
qa_lang
(
'users/password_wrong'
);
}
}
else
{
}
else
{
if
(
strtolower
(
qa_db_calc_passcheck
(
$inpassword
,
$userinfo
[
'passsalt'
]))
==
strtolower
(
$userinfo
[
'passcheck'
]))
{
// login and redirect
if
(
!
$legacyPassOk
)
{
$errors
[
'password'
]
=
qa_lang
(
'users/password_wrong'
);
require_once
QA_INCLUDE_DIR
.
'app/users.php'
;
}
qa_set_logged_in_user
(
$inuserid
,
$userinfo
[
'handle'
],
!
empty
(
$inremember
));
}
$topath
=
qa_get
(
'to'
);
if
(
!
isset
(
$errors
[
'password'
]))
{
// login and redirect
require_once
QA_INCLUDE_DIR
.
'app/users.php'
;
qa_set_logged_in_user
(
$inuserid
,
$userinfo
[
'handle'
],
!
empty
(
$inremember
));
if
(
isset
(
$topath
))
$topath
=
qa_get
(
'to'
);
qa_redirect_raw
(
qa_path_to_root
()
.
$topath
);
// path already provided as URL fragment
elseif
(
$passwordsent
)
qa_redirect
(
'account'
);
else
qa_redirect
(
''
);
}
else
if
(
isset
(
$topath
))
$errors
[
'password'
]
=
qa_lang
(
'users/password_wrong'
);
qa_redirect_raw
(
qa_path_to_root
()
.
$topath
);
// path already provided as URL fragment
elseif
(
$passwordsent
)
qa_redirect
(
'account'
);
else
qa_redirect
(
''
);
}
}
}
else
}
else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment