Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login page #1780

Merged
merged 28 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2bd4f6b
Barebones login page
rafalp Aug 1, 2024
9fa3033
Make SignInButton component always link to login page
rafalp Aug 1, 2024
41c33c7
Add forgotten password link to sign in page
rafalp Aug 1, 2024
ae45ae0
Login required decorator and unify get context to get context data
rafalp Aug 1, 2024
32fc957
Update hooks reference
rafalp Aug 1, 2024
07c3687
Move old login flow to reuse
rafalp Aug 1, 2024
5a64e0c
Rename login_view to login
rafalp Aug 1, 2024
58e120a
Make inputs on login form font size 16px to prevent ios zoom
rafalp Aug 1, 2024
d5cbab0
Add a lot css utilities, redesign sign in auth form
rafalp Aug 2, 2024
106ee11
More style tweaks to social login pages
rafalp Aug 2, 2024
d63444c
Basic tests for login page, redirect to next page from login page
rafalp Aug 3, 2024
b09ac24
If next page is current login page, discard next url
rafalp Aug 3, 2024
a14d149
Remove useless protection from circular redirects
rafalp Aug 3, 2024
a04ddcf
Another tweak to redirect after login
rafalp Aug 3, 2024
a7f20d2
Display social login buttons on login page
rafalp Aug 3, 2024
02f6970
Add get_login_url utility
rafalp Aug 3, 2024
4c7b755
Return 404 for login page when custom login url is defined
rafalp Aug 3, 2024
6a385a9
Make login disable check overrideable
rafalp Aug 3, 2024
b301206
Update login urls in emails
rafalp Aug 3, 2024
0da9def
Fix sign in button for delegated auth, add delegated auth sign in page
rafalp Aug 3, 2024
be769a5
Add tests for login required decorator
rafalp Aug 3, 2024
cea1dec
Display banned page when user is banned
rafalp Aug 3, 2024
19f4bc2
Add more tests for login flow
rafalp Aug 3, 2024
b8c0bda
Add successful login auth test to login decorator
rafalp Aug 3, 2024
70a8da5
Let banned admins sign in
rafalp Aug 3, 2024
46a0584
Dont sign in deactivated accounts
rafalp Aug 3, 2024
8610dcd
Add plugin outlets to the login page
rafalp Aug 3, 2024
41f9307
Tweak design and responsiveness of login page
rafalp Aug 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# `get_category_threads_page_context_hook`
# `get_category_threads_page_context_data_hook`

This hook wraps the standard function that Misago uses to get the template for the category threads page.
This hook wraps the standard function that Misago uses to get the template context data for the category threads page.


## Location

This hook can be imported from `misago.threads.hooks`:

```python
from misago.threads.hooks import get_category_threads_page_context_hook
from misago.threads.hooks import get_category_threads_page_context_data_hook
```


## Filter

```python
def custom_get_category_threads_page_context_filter(
action: GetCategoryThreadsPageContextHookAction,
def custom_get_category_threads_page_context_data_filter(
action: GetCategoryThreadsPageContextDataHookAction,
request: HttpRequest,
kwargs: dict,
) -> dict:
Expand All @@ -28,9 +28,9 @@ A function implemented by a plugin that can be registered in this hook.

### Arguments

#### `action: GetCategoryThreadsPageContextHookAction`
#### `action: GetCategoryThreadsPageContextDataHookAction`

A standard Misago function used to get the template context for the category threads page.
A standard Misago function used to get the template context data for the category threads page.

See the [action](#action) section for details.

Expand All @@ -47,17 +47,17 @@ A Python `dict` with view's keyword arguments.

### Return value

A Python `dict` with context to use to `render` the category threads page.
A Python `dict` with context data to use to `render` the category threads page.


## Action

```python
def get_category_threads_page_context_action(request: HttpRequest, kwargs: dict) -> dict:
def get_category_threads_page_context_data_action(request: HttpRequest, kwargs: dict) -> dict:
...
```

A standard Misago function used to get the template context for the category threads page.
A standard Misago function used to get the template context data for the category threads page.


### Arguments
Expand All @@ -74,19 +74,19 @@ A Python `dict` with view's keyword arguments.

### Return value

A Python `dict` with context to use to `render` the category threads page.
A Python `dict` with context data to use to `render` the category threads page.


## Example

The code below implements a custom filter function that adds custom context to the category threads page:
The code below implements a custom filter function that adds custom context data to the category threads page:

```python
from django.http import HttpRequest
from misago.threads.hooks import get_category_threads_page_context_hook
from misago.threads.hooks import get_category_threads_page_context_data_hook


@get_category_threads_page_context_hook.append_filter
@get_category_threads_page_context_data_hook.append_filter
def include_custom_context(action, request: HttpRequest, kwargs: dict) -> dict:
context = action(request, kwargs)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# `get_private_threads_page_context_hook`
# `get_private_threads_page_context_data_hook`

This hook wraps the standard function that Misago uses to get the template for the private threads page.
This hook wraps the standard function that Misago uses to get the template context data for the private threads page.


## Location

This hook can be imported from `misago.threads.hooks`:

```python
from misago.threads.hooks import get_private_threads_page_context_hook
from misago.threads.hooks import get_private_threads_page_context_data_hook
```


## Filter

```python
def custom_get_private_threads_page_context_filter(
action: GetPrivateThreadsPageContextHookAction,
def custom_get_private_threads_page_context_data_filter(
action: GetPrivateThreadsPageContextDataHookAction,
request: HttpRequest,
kwargs: dict,
) -> dict:
Expand All @@ -28,9 +28,9 @@ A function implemented by a plugin that can be registered in this hook.

### Arguments

#### `action: GetPrivateThreadsPageContextHookAction`
#### `action: GetPrivateThreadsPageContextDataHookAction`

A standard Misago function used to get the template context for the private threads page.
A standard Misago function used to get the template context data for the private threads page.

See the [action](#action) section for details.

Expand All @@ -47,17 +47,17 @@ A Python `dict` with view's keyword arguments.

### Return value

A Python `dict` with context to use to `render` the private threads page.
A Python `dict` with context data to use to `render` the private threads page.


## Action

```python
def get_private_threads_page_context_action(request: HttpRequest, kwargs: dict) -> dict:
def get_private_threads_page_context_data_action(request: HttpRequest, kwargs: dict) -> dict:
...
```

A standard Misago function used to get the template context for the private threads page.
A standard Misago function used to get the template context data for the private threads page.


### Arguments
Expand All @@ -74,19 +74,19 @@ A Python `dict` with view's keyword arguments.

### Return value

A Python `dict` with context to use to `render` the private threads page.
A Python `dict` with context data to use to `render` the private threads page.


## Example

The code below implements a custom filter function that adds custom context to the private threads page:
The code below implements a custom filter function that adds custom context data to the private threads page:

```python
from django.http import HttpRequest
from misago.threads.hooks import get_private_threads_page_context_hook
from misago.threads.hooks import get_private_threads_page_context_data_hook


@get_private_threads_page_context_hook.append_filter
@get_private_threads_page_context_data_hook.append_filter
def include_custom_context(action, request: HttpRequest, : dict) -> dict:
context = action(request, kwargs)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# `get_threads_page_context_hook`
# `get_threads_page_context_data_hook`

This hook wraps the standard function that Misago uses to get the template for the threads page.
This hook wraps the standard function that Misago uses to get the template context data for the threads page.


## Location

This hook can be imported from `misago.threads.hooks`:

```python
from misago.threads.hooks import get_threads_page_context_hook
from misago.threads.hooks import get_threads_page_context_data_hook
```


## Filter

```python
def custom_get_threads_page_context_filter(
action: GetThreadsPageContextHookAction,
def custom_get_threads_page_context_data_filter(
action: GetThreadsPageContextDataHookAction,
request: HttpRequest,
kwargs: dict,
) -> dict:
Expand All @@ -28,9 +28,9 @@ A function implemented by a plugin that can be registered in this hook.

### Arguments

#### `action: GetThreadsPageContextHookAction`
#### `action: GetThreadsPageContextDataHookAction`

A standard Misago function used to get the template context for the threads page.
A standard Misago function used to get the template context data for the threads page.

See the [action](#action) section for details.

Expand All @@ -47,17 +47,17 @@ A Python `dict` with view's keyword arguments.

### Return value

A Python `dict` with context to use to `render` the threads page.
A Python `dict` with context data to use to `render` the threads page.


## Action

```python
def get_threads_page_context_action(request: HttpRequest, kwargs: dict) -> dict:
def get_threads_page_context_data_action(request: HttpRequest, kwargs: dict) -> dict:
...
```

A standard Misago function used to get the template context for the threads page.
A standard Misago function used to get the template context data for the threads page.


### Arguments
Expand All @@ -74,19 +74,19 @@ A Python `dict` with view's keyword arguments.

### Return value

A Python `dict` with context to use to `render` the threads page.
A Python `dict` with context data to use to `render` the threads page.


## Example

The code below implements a custom filter function that adds custom context to the threads page:
The code below implements a custom filter function that adds custom context data to the threads page:

```python
from django.http import HttpRequest
from misago.threads.hooks import get_threads_page_context_hook
from misago.threads.hooks import get_threads_page_context_data_hook


@get_threads_page_context_hook.append_filter
@get_threads_page_context_data_hook.append_filter
def include_custom_context(action, request: HttpRequest, kwargs: dict) -> dict:
context = action(request, kwargs)

Expand Down
6 changes: 3 additions & 3 deletions dev-docs/plugins/hooks/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ Hooks instances are importable from the following Python modules:

`misago.threads.hooks` defines the following hooks:

- [`get_category_threads_page_context_hook`](./get-category-threads-page-context-hook.md)
- [`get_category_threads_page_context_data_hook`](./get-category-threads-page-context-data-hook.md)
- [`get_category_threads_page_filters_hook`](./get-category-threads-page-filters-hook.md)
- [`get_category_threads_page_moderation_actions_hook`](./get-category-threads-page-moderation-actions-hook.md)
- [`get_category_threads_page_queryset_hook`](./get-category-threads-page-queryset-hook.md)
- [`get_category_threads_page_subcategories_hook`](./get-category-threads-page-subcategories-hook.md)
- [`get_category_threads_page_threads_hook`](./get-category-threads-page-threads-hook.md)
- [`get_private_threads_page_context_hook`](./get-private-threads-page-context-hook.md)
- [`get_private_threads_page_context_data_hook`](./get-private-threads-page-context-data-hook.md)
- [`get_private_threads_page_filters_hook`](./get-private-threads-page-filters-hook.md)
- [`get_private_threads_page_queryset_hook`](./get-private-threads-page-queryset-hook.md)
- [`get_private_threads_page_threads_hook`](./get-private-threads-page-threads-hook.md)
- [`get_threads_page_context_hook`](./get-threads-page-context-hook.md)
- [`get_threads_page_context_data_hook`](./get-threads-page-context-data-hook.md)
- [`get_threads_page_filters_hook`](./get-threads-page-filters-hook.md)
- [`get_threads_page_moderation_actions_hook`](./get-threads-page-moderation-actions-hook.md)
- [`get_threads_page_queryset_hook`](./get-threads-page-queryset-hook.md)
Expand Down
16 changes: 11 additions & 5 deletions frontend/src/components/SignInButton/SignInButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,26 @@ export default function SignInButton({ block, className, onClick }) {
"btn-block": block,
})}
href={settings.LOGIN_URL}
onClick={onClick}
onClick={() => {
if (onClick) {
onClick()
}
}}
>
{pgettext("cta", "Sign in")}
</a>
)
}

return (
<button
<a
className={classnames("btn btn-sign-in", className, {
"btn-block": block,
})}
type="button"
onClick={() => {
href={settings.LOGIN_URL}
onClick={(event) => {
event.preventDefault()

if (onClick) {
onClick()
}
Expand All @@ -35,6 +41,6 @@ export default function SignInButton({ block, className, onClick }) {
}}
>
{pgettext("cta", "Sign in")}
</button>
</a>
)
}
4 changes: 2 additions & 2 deletions frontend/src/components/reset-password-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ export default class extends React.Component {
complete = (apiResponse) => {
auth.softSignOut()

// nuke "redirect_to" field so we don't end
// nuke "next" field so we don't end
// coming back to error page after sign in
$('#hidden-login-form input[name="redirect_to"]').remove()
$('#hidden-login-form input[name="next"]').remove()

ReactDOM.render(
<PasswordChangedPage user={apiResponse} />,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/sign-in.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default class extends Form {
// Misago to redirect user back to right page, and will trigger browser's
// key ring feature
form.find('input[type="hidden"]').val(ajax.getCsrfToken())
form.find('input[name="redirect_to"]').val(window.location.pathname)
form.find('input[name="next"]').val(window.location.pathname)
form.find('input[name="username"]').val(this.state.username)
form.find('input[name="password"]').val(this.state.password)
form.submit()
Expand Down
60 changes: 0 additions & 60 deletions frontend/src/style/flavor/social-buttons.less
Original file line number Diff line number Diff line change
@@ -1,63 +1,3 @@
//
// Social Buttons Flavor
// --------------------------------------------------

// Those buttons simply add brand color over the .btn-default
.misago-social-btn(@color) {
&,
&:disabled,
&:disabled:hover {
color: @color;
font-weight: bold;
}
}

.btn-social-battlenet,
.btn-social-battlenet-oauth2 {
.misago-social-btn(#0e86ca);
}

.btn-social-bungie {
.misago-social-btn(#0096db);
}

.btn-social-facebook,
.btn-social-facebook-app {
.misago-social-btn(#3b5998);
}

.btn-social-github,
.btn-social-github-team,
.btn-social-github-enterprise,
.btn-social-github-enterprise-org,
.btn-social-github-enterprise-team {
.misago-social-btn(#000000);
}

.btn-social-gitlab {
.misago-social-btn(#fc6d26);
}

.btn-social-google,
.btn-social-google-oauth,
.btn-social-google-oauth2,
.btn-social-google-plus,
.btn-social-google-openidconnect {
.misago-social-btn(#dd4b39);
}

.btn-social-linkedin {
.misago-social-btn(#0077b5);
}

.btn-social-steam {
.misago-social-btn(#5c7e10);
}

.btn-social-twitter {
.misago-social-btn(#1da1f2);
}

.form-social-auth {
.row {
margin-top: @padding-base-vertical * -1;
Expand Down
Loading
Loading