text stringlengths 0 234 |
|---|
procedure Free is |
new Ada.Unchecked_Deallocation (Object => Name_Array, |
Name => Name_Array_Access); |
Left : Index_Type := Index_Type'First + 1; |
Right : Index_Type := Last_Index; |
begin |
-- Check the storage and allocate it if necessary. |
if Indexes = null then |
Indexes := new Name_Pair_Array (Index_Type'First + 1 .. Index_Type'First + 10); |
Names := new Name_Array (Index_Type'First + 1 .. Index_Type'First + 10); |
elsif Indexes'Last = Last_Index then |
declare |
E : constant Name_Pair_Array_Access |
:= new Name_Pair_Array (1 .. Last_Index + 10); |
N : constant Name_Array_Access := new Name_Array (1 .. Last_Index + 10); |
begin |
E (Indexes'Range) := Indexes.all; |
N (Names'Range) := Names.all; |
Free (Indexes); |
Free (Names); |
Names := N; |
Indexes := E; |
Function Definition: procedure Update_User; |
Function Body: OpenId : constant String := Security.Auth.Get_Claimed_Id (Auth); |
Email : constant String := Security.Auth.Get_Email (Auth); |
Ctx : constant Contexts.Service_Context_Access := AWA.Services.Contexts.Current; |
DB : Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx); |
Query : ADO.SQL.Query; |
Found : Boolean; |
User : User_Ref; |
Session : Session_Ref; |
-- ------------------------------ |
-- Update the user first name/last name |
-- ------------------------------ |
procedure Update_User is |
Name : constant String := Security.Auth.Get_Full_Name (Auth); |
First_Name : constant String := Security.Auth.Get_First_Name (Auth); |
Last_Name : constant String := Security.Auth.Get_Last_Name (Auth); |
Sep : constant Natural := Util.Strings.Index (Name, ' '); |
begin |
if Name'Length > 0 and Name /= String '(User.Get_Name) then |
User.Set_Name (Name); |
end if; |
if First_Name'Length > 0 and First_Name /= String '(User.Get_First_Name) then |
User.Set_First_Name (First_Name); |
end if; |
if Last_Name'Length > 0 and Last_Name /= String '(User.Get_Last_Name) then |
User.Set_Last_Name (Last_Name); |
end if; |
if Sep > 0 and String '(User.Get_First_Name) = "" then |
User.Set_First_Name (Name (Name'First .. Sep - 1)); |
end if; |
if Sep > 0 and String '(User.Get_Last_Name) = "" then |
User.Set_Last_Name (Name (Sep + 1 .. Name'Last)); |
end if; |
if Name'Length > 0 and String '(User.Get_First_Name) = "" then |
User.Set_First_Name (Name); |
end if; |
if Name'Length = 0 then |
User.Set_Name (Get_Name_From_Email (Email => Email)); |
end if; |
User.Save (DB); |
end Update_User; |
begin |
Log.Info ("Authenticated user {0}", Email); |
Ctx.Start; |
-- Find the user registered under the given OpenID identifier. |
Query.Bind_Param (1, OpenId); |
Query.Set_Filter ("o.open_id = ?"); |
User.Find (DB, Query, Found); |
if not Found then |
Log.Info ("User {0} is not known", Email); |
declare |
E : Email_Ref; |
begin |
E.Set_Email (Email); |
E.Set_User_Id (0); |
E.Save (DB); |
User.Set_Email (E); |
User.Set_Open_Id (OpenId); |
Update_User; |
E.Set_User_Id (User.Get_Id); |
E.Save (DB); |
Function Definition: procedure Register (Plugin : in out Module; |
Function Body: Name : in String; |
Bind : in ASF.Beans.Class_Binding_Access) is |
begin |
Plugin.App.Register_Class (Name, Bind); |
end Register; |
-- ------------------------------ |
-- Finalize the module. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.