Skip to content

Conversation

@joshtrichards
Copy link
Member

@joshtrichards joshtrichards commented Dec 29, 2025

  • Resolves: #

Summary

Just a minor/tiny refinement for readability, maintainability, and robustness.

  • Use $request->getCookie() instead of $_COOKIE directly
  • Assign dependencies to variables up front for readability.
  • Note exceptions from each login method are possible and are not handled here / must be handled by callers.

TODO

  • ...

Checklist

- Use $request->getCookie() instead of $_COOKIE directly for consistency.
- Assign dependencies via variables up front for readability.
- Note exceptions from each login method is possible and are not handled here / must be handled by callers.

Just minor refinements to readability, maintainability, and some aspects of robustness.

Signed-off-by: Josh <[email protected]>
Signed-off-by: Josh <[email protected]>
@joshtrichards joshtrichards changed the title refactor(auth): improve robustness and readability of handleLogin refactor(auth):Use $request->getCookie() instead of $_COOKIE Dec 30, 2025
@joshtrichards joshtrichards added 3. to review Waiting for reviews feature: authentication ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring) labels Dec 30, 2025
@joshtrichards joshtrichards changed the title refactor(auth):Use $request->getCookie() instead of $_COOKIE refactor(auth): Use $request->getCookie() instead of $_COOKIE Dec 30, 2025
@joshtrichards joshtrichards marked this pull request as ready for review December 30, 2025 16:46
@joshtrichards joshtrichards requested a review from a team as a code owner December 30, 2025 16:46
@joshtrichards joshtrichards requested review from Altahrim, leftybournes, salmart-dev and yemkareems and removed request for a team December 30, 2025 16:46
@joshtrichards joshtrichards added this to the Nextcloud 33 milestone Dec 30, 2025
Comment on lines +1193 to +1202
if (
$request->getCookie('nc_username') !== null
&& $request->getCookie('nc_token') !== null
&& $request->getCookie('nc_session_id') !== null
&& $userSession->loginWithCookie(
$request->getCookie('nc_username'),
$request->getCookie('nc_token'),
$request->getCookie('nc_session_id')
)
) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps a more readable version?

$username = $request->getCookie('nc_username');
$token = $request->getCookie('nc_token');
$sessionId = $request->getCookie('nc_session_id');

if (
	$username !== null
	&& $token !== null
	&& $sessionId !== null
	&& $userSession->loginWithCookie($username, $token, $sessionId)
) {

@nextcloud-bot nextcloud-bot mentioned this pull request Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews feature: authentication ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants