Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- proc:BEGIN
- /** --------
- * Author: Yamachi
- * Date: 09/02/2011
- ** --------
- * Handles login attempts.
- ** --------
- **/
- /** ----------------------------- **/
- /* Auth results */
- DECLARE Success, # Login succeeded
- Fail, # Login failed (wrong username or pass)
- Logged_In, # Account is already logged in
- Maintenance, # Server is undergoing maintenance
- Expired, # Account playtime has expired (was used during CABAL's very brief p2p moment)
- IP_Blocked, # IP is blocked
- Blocked, # Account is blocked
- Trial, # Free trial period (?) No idea what this is for
- Cafe, # Internet cafe account (must log in from a cafe)
- Unauthorised, # Account not authorised (need to verify email address)
- Password_Block int; # Account termporarily blocked for security measures (too many incorrect password attempts)
- /* Account data */
- DECLARE _usernum,
- _authtype,
- _login int;
- DECLARE _identityno char(13);
- /* blah */
- DECLARE _authkey varchar(32);
- /** ----------------------------- **/
- /* Set the auth results constants */
- SET Success = 32,
- Fail = 33,
- Logged_In = 34,
- Maintenance = 35,
- Expired = 36,
- IP_Blocked = 37,
- Blocked = 38,
- Trial = 39,
- Cafe = 40,
- Unauthorised = 41,
- Password_Block = 42;
- /** ----------------------------- **/
- /* Grab user info */
- SELECT SQL_CALC_FOUND_ROWS UserNum, AuthType, IdentityNo, Login
- FROM cabal_auth_table
- WHERE ID = id and Password = PASSWORD(pass)
- INTO _usernum, _authtype, _identityno, _login;
- /* Check to see if account info was incorrect */
- IF FOUND_ROWS() = 0 THEN
- COMMIT;
- SELECT Fail;
- LEAVE proc;
- END IF;
- /* Check to see if account is blocked */
- IF _authtype = 2 THEN
- COMMIT;
- SELECT Blocked, _usernum, 0;
- LEAVE proc;
- END IF;
- /* Not sure what this is for */
- IF _authtype = 3 THEN
- SET _identityno = SUBSTRING(_indentityno, 1, 6) + '0000001';
- END IF;
- /* TODO: Check if IP is banned */
- /* Check to see if account is already logged in */
- IF _login != 0 THEN
- COMMIT;
- SELECT Logged_In, _usernum, _login;
- LEAVE proc;
- END IF;
- /* TODO: Check premium status */
- /* Generate and update AuthKey */
- SET _authkey = REPLACE(UUID(), '-', '');
- UPDATE cabal_auth_table
- SET Login = _login, LoginTime = CURDATE(), LastIp = ip, AuthKey = _authkey
- WHERE UserNum = _usernum;
- /* Login succeeded */
- SELECT Success,
- _usernum,
- _login,
- _identityno,
- 0, # Type
- 0, # Premium time left in seconds
- 0, # PayMinutes (?)
- 0, # IsFreeIp (wtf is this?)
- 0, # ServiceKind
- _authkey;
- COMMIT;
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement