Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides the login interface for Matterhorn.
- Overview
The interface provides a set of form fields for the user to use to enter their server information and credentials. The user enters this information and presses Enter, and then this module attempts to connect to the server. The module's main function, interactiveGetLoginSession, returns the result of that connection attempt, if any.
- Details
The interactiveGetLoginSession function takes the Matterhorn configuration's initial connection information as input. If the configuration provided a complete set of values needed to make a login attempt, this module goes ahead and immediately makes a login attempt before even showing the user the login form. This case is the case where the configuration provided all four values needed: server host name, port, username, and password. When the interface immediately makes a login attempt under these conditions, this is referred to as an "initial" attempt in various docstrings below. Otherwise, the user is prompted to fill out the form to enter any missing values. On pressing Enter, a login attempt is made.
A status message about whether a connection is underway is shown in both cases: in the case where the user has edited the credentials and pressed Enter, and in the case where the original credentials provided to interactiveGetLoginSession caused an initial connection attempt.
The "initial" login case is special because in addition to not
showing the form, we want to ensure that the "connecting to..."
status message that is shown is shown long enough for the user to
see what is happening (rather than just flashing by in the case
of a fast server connection). For this usability reason, we have
a "startup timer" thread: the thread waits a specified number
of milliseconds (see startupTimerMilliseconds
below) and then
notifies the interface that it has timed out. If there is an initial
connection attempt underway that succeeds *before* the timer
fires, we wait until the timer fires before quitting the Login
application and returning control to Matterhorn. This ensures that
the "connecting to..." message stays on the screen long enough to not
be jarring, and to show the user what is happening. If the connection
fails before the timer fires, we just resume normal operation and
show the login form so the user can intervene.
Synopsis
- data LoginAttempt
- interactiveGetLoginSession :: Vty -> IO Vty -> (ConnectionData -> ConnectionData) -> LogManager -> ConnectionInfo -> IO (Maybe LoginAttempt, Vty)
Documentation
data LoginAttempt Source #
The result of an authentication attempt.
AttemptFailed AuthenticationException | The attempt failed with the corresponding error. |
AttemptSucceeded ConnectionInfo ConnectionData Session User (Maybe Text) | The attempt succeeded. |
interactiveGetLoginSession Source #
:: Vty | The initial terminal state handle to use. |
-> IO Vty | An action to build a new state handle if one is needed. (In practice this never fires since the login app doesn't use suspendAndResume, but we need it to satisfy the Brick API.) |
-> (ConnectionData -> ConnectionData) | The function to set the logger on connection handles. |
-> LogManager | The log manager used to do logging. |
-> ConnectionInfo | Initial connection info to use to populate the login form. If the connection info provided here is fully populated, an initial connection attempt is made without first getting the user to hit Enter. |
-> IO (Maybe LoginAttempt, Vty) |
The main function of this module: interactively present a login interface, get the user's input, and attempt to log into the user's specified mattermost server.
This always returns the final terminal state handle. If the user makes no login attempt, this returns Nothing. Otherwise it returns Just the result of the latest attempt.