# Eenvoudig inloggen via e-mail met deep links die een gebruikersnaam bevatten

**URL:** https://meta.discourse.org/t/simple-login-by-email-via-deep-links-containing-a-username/286910
**Category:** Feature
**Created:** [29 november 2023 om 00:25 UTC](https://meta.discourse.org/t/simple-login-by-email-via-deep-links-containing-a-username/286910 "2023-11-29T00:25:52Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![thoka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thoka/32/115652_2.png) [@thoka](https://meta.discourse.org/u/thoka)
#### Post date: [29 november 2023 om 00:25 UTC](https://meta.discourse.org/t/simple-login-by-email-via-deep-links-containing-a-username/286910/1 "2023-11-29T00:25:52Z")

</div>

I would like to lower the hurdle to login in our school forum by the following procedure:

1. Links sent by mail to the (mostly non-public) forum should contain the username of the addressed user (like `forum.my.tld/t/123#user=toka`)

2. If a not logged-in user opens this link, a page offers to send a login link by clicking a button.

3. If clicked, a login with a login token should be sent to the user, which then allows them to open the target page without further interaction for a specific time. Otherwise, a “resend login link” button should be offered.

Has this already been implemented somewhere?

If not: which machinery exists, which could be used to implement it?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [29 november 2023 om 10:32 UTC](https://meta.discourse.org/t/simple-login-by-email-via-deep-links-containing-a-username/286910/2 "2023-11-29T10:32:53Z")

</div>

You want to use [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) such that users logged in to your system are also logged into Discourse.

[Setup DiscourseConnect - Official Single-Sign-On for Discourse (sso)](https://meta.discourse.org/t/setup-discourseconnect-official-single-sign-on-for-discourse-sso/13045)

---

<div class="post-metadata">

### Author: ![thoka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thoka/32/115652_2.png) [@thoka](https://meta.discourse.org/u/thoka)
#### Post date: [29 november 2023 om 22:03 UTC](https://meta.discourse.org/t/simple-login-by-email-via-deep-links-containing-a-username/286910/3 "2023-11-29T22:03:27Z")

</div>

There is no other system.  
Most of the users use the forum only by mail.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [30 november 2023 om 01:14 UTC](https://meta.discourse.org/t/simple-login-by-email-via-deep-links-containing-a-username/286910/4 "2023-11-30T01:14:49Z")

</div>

We already support login via email:

 ![image](https://global.discourse-cdn.com/meta/original/4X/d/d/6/dd6e8104b501ac9b475882929b201f5c152882fa.png)

So automating/simplifying this is certainly feasible.

---

<div class="post-metadata">

### Author: ![thoka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thoka/32/115652_2.png) [@thoka](https://meta.discourse.org/u/thoka)
#### Post date: [30 november 2023 om 22:21 UTC](https://meta.discourse.org/t/simple-login-by-email-via-deep-links-containing-a-username/286910/5 "2023-11-30T22:21:14Z")

</div>

> [@sam](#):
>
> We already support login via email:

Yes. This is our prominent way to log into the forum. But for a big part of the users, this seems to be too difficult.

In addition, we face the problem that some users use non-identical email addresses in their communication. For example, `(at)gmail.com` and `(at)googlemail.com`, or email addresses with or without added dots in the username. They do not remember which email address they once wrote on the paper (yes, sorry, it’s Germany) registration form and are either unaware of these problems or of the possibility to learn about their “login email address” by checking their mail headers.

Therefore, I am investigating a way that links sent to users allow users to log in without further knowledge of how to use the Discourse login procedure.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [30 november 2023 om 22:23 UTC](https://meta.discourse.org/t/simple-login-by-email-via-deep-links-containing-a-username/286910/6 "2023-11-30T22:23:28Z")

</div>

> [@thoka](#):
>
> Therefore, I am investigating a way that links sent to users allow users to log in without further knowledge of how to use the Discourse login procedure.

There is certainly a security risk, if you are comfortable to accept it, some automation that generates the links we generate when you try to log in via email, is certainly feasible, as long as they already have accounts.

---

<div class="post-metadata">

### Author: ![thoka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thoka/32/115652_2.png) [@thoka](https://meta.discourse.org/u/thoka)
#### Post date: [30 november 2023 om 22:29 UTC](https://meta.discourse.org/t/simple-login-by-email-via-deep-links-containing-a-username/286910/7 "2023-11-30T22:29:03Z")

</div>

> [@sam](#):
>
> There is certainly a security risk

Hm. I tried to circumvent this in my proposal.  
I understand that links which would log users in directly are dangerous.

But with the suggested mechanism, the only risk I see is users getting unwanted login links sent to them.

---

<div class="post-metadata">

### Author: ![thoka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thoka/32/115652_2.png) [@thoka](https://meta.discourse.org/u/thoka)
#### Post date: [8 april 2024 om 07:34 UTC](https://meta.discourse.org/t/simple-login-by-email-via-deep-links-containing-a-username/286910/8 "2024-04-08T07:34:02Z")

</div>

I have a first working implementation:

[https://github.com/thoka/discourse-login-helper](https://github.com/thoka/discourse-login-helper)

Now I’m trying to learn how to decorate all links to discourse in notifications with user information.

---

<div class="post-metadata">

### Author: ![thoka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thoka/32/115652_2.png) [@thoka](https://meta.discourse.org/u/thoka)
#### Post date: [28 mei 2024 om 09:35 UTC](https://meta.discourse.org/t/simple-login-by-email-via-deep-links-containing-a-username/286910/9 "2024-05-28T09:35:34Z")

</div>

This feature is now implemented in

> [@Login Helper Plugin](https://meta.discourse.org/t/login-helper-plugin/309676):
>
> information_sourceSummary shorten process of logging in by emailhammer_and_wrenchRepository Link [https://github.com/thoka/discourse-login-helper/](https://github.com/thoka/discourse-login-helper/)open_bookInstall Guide [How to install plugins in Discourse](https://meta.discourse.org/t/install-plugins-in-discourse/19157)Features This Discourse plugin is an attempt to simplify the login process for novice, mass-subscribed users. Links to the forum in notification emails are enriched with the user’s email address. If a user follows one of these links, a login email is sent witho…

Where is the right place to ask for possibilities not to have to override core methods like

> <https://github.com/thoka/discourse-login-helper/blob/9fe18117c87139e3facf5673d55f5fce82258a52/assets/javascripts/discourse/initializers/login_helper.js#L10-L50>

and

> <https://github.com/thoka/discourse-login-helper/blob/9fe18117c87139e3facf5673d55f5fce82258a52/plugin.rb#L146-L177>

to redirect to a destination\_url after login

> <https://github.com/thoka/discourse-login-helper/blob/9fe18117c87139e3facf5673d55f5fce82258a52/assets/javascripts/discourse/initializers/login_helper.js#L31-L32>

?
