diff --git a/db/postgresql/openid_logs_10_01_19.sql b/db/postgresql/openid_logs_10_01_19.sql new file mode 100644 index 0000000000000000000000000000000000000000..ff9ba5bbfc036c53dadd367d35904ae51fd2539d --- /dev/null +++ b/db/postgresql/openid_logs_10_01_19.sql @@ -0,0 +1,33 @@ + +CREATE SEQUENCE seq_logs_signin_detailed + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +CREATE TABLE logs_signin_detailed ( + id integer DEFAULT nextval('seq_logs_signin_detailed'::regclass) NOT NULL, + accountid integer, + globalkey character varying NOT NULL, + isstudent integer, + isstaff integer, + error_message character varying, + date timestamp(0) without time zone DEFAULT now() NOT NULL +); + +CREATE INDEX key_logs_signin_detailed ON logs_signin_detailed USING btree (globalkey); + +ALTER TABLE ONLY logs_signin_detailed + ADD CONSTRAINT logs_signin_detailed_pkey PRIMARY KEY (id); + +CREATE OR REPLACE FUNCTION public.log_sigindetailed(paccountid integer, pisstaff integer, pisstudent integer, pglobalkey character varying, pmessage character varying) + RETURNS integer +LANGUAGE plpgsql +AS $function$ +begin + INSERT INTO logs_signin_detailed (AccountID, GlobalKey, IsStudent, IsStaff, error_message) VALUES (paccountid, pglobalkey, pisstudent, pisstaff, pmessage); + RETURN 0; +END +$function$; diff --git a/~dev_rating/application/classes/Controller/Handler/Sign.php b/~dev_rating/application/classes/Controller/Handler/Sign.php index 9d948088c5e92e4a33c0afa5cd4d4bbfff7ad2b7..28062fc63360f91d062b74c2f3ca69c26167519c 100644 --- a/~dev_rating/application/classes/Controller/Handler/Sign.php +++ b/~dev_rating/application/classes/Controller/Handler/Sign.php @@ -114,6 +114,7 @@ class Controller_Handler_Sign extends Controller_Handler $email = $_GET["openid_sreg_email"]; $id = 0; + $error = null; try { if ($isStudent) { $globalKey = 'st-' . str_pad(str_replace('st-', '', $globalKey), 9, '0', STR_PAD_LEFT); @@ -122,7 +123,9 @@ class Controller_Handler_Sign extends Controller_Handler $id = User::instance()->signInByOpenID($globalKey); } } catch (Exception $e) { - + $error = $e->getMessage(); + } finally { + Model_Logs::logSigninDetailed($id, $isStaff, $isStudent, $globalKey, $error); } if ($id <= 0) { diff --git a/~dev_rating/application/classes/Model/Logs.php b/~dev_rating/application/classes/Model/Logs.php index ba318091dca8554510fdc651c9d04a7a07904f6f..f1a0c82ab254d49c07ac509f43cf067d6b37b1c6 100644 --- a/~dev_rating/application/classes/Model/Logs.php +++ b/~dev_rating/application/classes/Model/Logs.php @@ -28,4 +28,17 @@ class Model_Logs extends Model return $result; } + public static function logSigninDetailed($accountID, $isStaff, $isStudent, $globalKey, $errorMessage) { + $query = 'SELECT * FROM log_sigindetailed(:account, :isstaff, :isstudent, :globalkey, :errormessage)'; + + $result = DB::query(Database::UPDATE, $query) + ->param(':account', $accountID) + ->param(':isstaff', $isStaff) + ->param(':isstudent', $isStudent) + ->param(':globalkey', $globalKey) + ->param(':errormessage', $errorMessage) + ->execute(); + return $result; + } + }