Ferreteria/v0.5/login/submit: Difference between revisions

From Woozle Writes Code
< Ferreteria‎ | v0.5‎ | login
Jump to navigation Jump to search
(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...")
 
(moved codesplaining to method's page (new))
Line 18: Line 18:
** '''Event log''': failed login, unknown user
** '''Event log''': failed login, unknown user
==Code==
==Code==
<code>{{arg|Account Feature}}->TryLogin($sUser,$sPass)</code> : handle the logic for user login attempt; do necessary bookkeeping for result
<code>{{l/ver/method|users/csLogin/TryLogin|csLogin::TryLogin}}($sUser,$sPass)}}</code> : handle the logic for user login attempt; do necessary bookkeeping for result
* &rarr; <code>{{arg|Account Storage Row}}->AuthorizeLogin($sUser,$sPass)</code> : lookup the given username, see if the password hash matches the stored hash
** Set the internal login status: <code>csLogin::SetAccountStatus({{arg|results of search for login name}})</code>
* Log the results (<code>$this->CreateEvent(...)</code>)
* On success:
** update the applicable Session record (<code>{{arg|Session Storage Row}}->UpdateForLogin($idAcct)</code>)

Revision as of 14:52, 30 March 2022

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

Template:L/ver/method($sUser,$sPass)}} : handle the logic for user login attempt; do necessary bookkeeping for result