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

Provide better indication of anonymous or logged in status #32

Open
therealbstern opened this issue Oct 27, 2017 · 2 comments
Open

Provide better indication of anonymous or logged in status #32

therealbstern opened this issue Oct 27, 2017 · 2 comments

Comments

@therealbstern
Copy link
Collaborator

therealbstern commented Oct 27, 2017

From #3:

We track the user that is associated with a ConnectionSignature, which is returned by the run method. That can be used as a key to store session information, although it can change, so is awkward on the application side. The get_user method returns the user logged in on that session, if any.

What @jolhoeft is thinking of is something to replace the run method, say get_connection, that returns an enum:

enum ConnectionType {
  Anonymous(ConnectionSignature),
  LoggedIn(ConnectionSignature, String),
}

We include the ConnectionSignature in the logged in case so the application can migrate information after the user logs in (or more likely, creates an account).

This can all be done on the application side now, but is a bit messy, and seems a common use case.

We'll also need:

fn upgrade_connection(c: ConnectionType, user: &str) -> ConnectionType

which consumes c, and returns a ConnectionType::LoggedIn if the user was not zero-length (otherwise it gives you back a ConnectionType::Anonymous again).

@therealbstern
Copy link
Collaborator Author

FWIW, the get_user method was designed to differentiate between logged-in users and anonymous users (as well as to identify the logged-in user specifically).

@therealbstern
Copy link
Collaborator Author

I sort of feel like this could be managed equally well with a "is this session authenticated" boolean that lives in the application, but if we want to own session variables, this is the right path to take.

Also I think we should own session variables, since this is "websession.rs", not "weblogin.rs".

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

No branches or pull requests

1 participant