Ferreteria/v0.5/login/submit

From Woozle Writes Code
< Ferreteria‎ | v0.5‎ | login
Revision as of 15:37, 24 March 2022 by htyp>Woozle (Created page with "==Process== This happens when the user submits a username and password. * Search for username in the Accounts table. * If found: ** Check password match ** If matched: *** (lo...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Process

This happens when the user submits a username and password.

  • Search for username in the Accounts table.
  • If found:
    • Check password match
    • If matched:
      • (login conditions satisfied for now -- though eventually we'll want to check account status in case it is suspended (not yet supported))
      • Find/create Session record for user's browser
      • Session bookkeeping: (a) save Account ID, (b) update WhenUsed
      • Account bookkeeping: update WhenLogin
      • Login object bookkeeping: (a) save Session and Account; (b) note success
      • Event log: successful login
    • Else (if not matched)
      • Login object bookkeeping: (a) save Account; (b) note failure
      • Event log: failed login, bad pw
  • Else (if not found)
    • Login object bookkeeping: note login-failed
    • Event log: failed login, unknown user

Code

<Account Feature>->TryLogin($sUser,$sPass) : handle the logic for user login attempt; do necessary bookkeeping for result

  • <Account Storage Row>->AuthorizeLogin($sUser,$sPass) : lookup the given username, see if the password hash matches the stored hash
    • Set the internal login status: csLogin::SetAccountStatus(<results of search for login name>)
  • Log the results ($this->CreateEvent(...))
  • On success:
    • update the applicable Session record (<Session Storage Row>->UpdateForLogin($idAcct))