Skip to content

Fix false FALoginCookieError#99

Closed
mruac wants to merge 1 commit intoDeer-Spangle:masterfrom
mruac:ensure_login-fix
Closed

Fix false FALoginCookieError#99
mruac wants to merge 1 commit intoDeer-Spangle:masterfrom
mruac:ensure_login-fix

Conversation

@mruac
Copy link
Copy Markdown
Contributor

@mruac mruac commented Nov 5, 2022

The ensure_login! method was always returning the FALoginCookieError due to the @user_cookie returning true, so I just made it false so it won't return the error.

The `ensure_login!` method was always returning the `FALoginCookieError` due to the `@user_cookie` returning true, so I just made it false so it won't return the error.

def ensure_login!
return if @user_cookie
return if !@user_cookie

Check notice

Code scanning / Rubocop

Favor unless over if for negative conditions (or control flow or).

Style/NegatedIf: Favor `unless` over `if` for negative conditions.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Gosh, these rubocop warnings are way noisier than I would like

@Deer-Spangle
Copy link
Copy Markdown
Owner

The user cookie is set on line 290 of that file, in the before block that runs before every request. It reads the HTTP_FA_COOKIE for each request, so it'll be truthy if that header is provided, and false otherwise.
Hence why this ensure_login method checks if it is truthy, and raises an exception if not. It's the protection against use of those endpoints without the user specifies their own cookies, rather than using the server default ones

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants