Changeset 69 for trunk/Components
- Timestamp:
- Dec 30, 2011, 6:00:53 PM (13 years ago)
- Location:
- trunk/Components/CoolWeb
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Components/CoolWeb/Modules/UUser.pas
r61 r69 18 18 19 19 TWebUser = class 20 Id: Integer; 21 Name: string; 20 22 FullName: string; 23 Email: string; 21 24 Database: TSqlDatabase; 22 25 HandlerData: THTTPHandlerData; … … 25 28 function GetIdByName(Name: string): Integer; 26 29 function GetIdByNamePassword(Name: string; PassWord: string): Integer; 30 procedure Load; 27 31 end; 28 32 … … 42 46 43 47 resourcestring 44 SDuplicateUserItem = 'User name already used.'; 48 SDuplicateUserItem = 'User name "%s" already used.'; 49 SEmptyUserParameters = 'Missing user parameters'; 50 SUserNotFound = 'User "%s" not found'; 45 51 46 52 { TOnlineUser } … … 123 129 DbRows: TDbRows; 124 130 begin 131 if (Name = '') or (Password = '') or (Email = '') then raise Exception.Create(SEmptyUserParameters); 125 132 try 126 133 DbRows := TDbRows.Create; … … 131 138 Name + '", SHA1(CONCAT("' + Password + '", "' + Salt + '")), "' + Salt + 132 139 '", "' + Email + '", NOW())'); 133 end else raise EDuplicateItem.Create( SDuplicateUserItem);140 end else raise EDuplicateItem.Create(Format(SDuplicateUserItem, [Name])); 134 141 finally 135 142 DbRows.Free; … … 145 152 Database.Query(DbRows, 'SELECT `Id` FROM `User` WHERE `Name`="' + Name + '"'); 146 153 if DbRows.Count = 1 then Result := StrToInt(DbRows[0].Items[0].Value) 147 else raise ENotFound.Create( 'User "' + Name + '" not found');154 else raise ENotFound.Create(Format(SUserNotFound, [Name])); 148 155 finally 149 156 DBRows.Free; … … 160 167 '`Password` = SHA1(CONCAT("' + Password + '", Salt))'); 161 168 if DbRows.Count = 1 then Result := StrToInt(DbRows[0].Items[0].Value) 162 else raise ENotFound.Create('User "' + Name + '" not found'); 169 else raise ENotFound.Create(Format(SUserNotFound, [Name])); 170 finally 171 DBRows.Free; 172 end; 173 end; 174 175 procedure TWebUser.Load; 176 var 177 DbRows: TDbRows; 178 begin 179 try 180 DbRows := TDbRows.Create; 181 Database.Query(DbRows, 'SELECT * FROM `User` WHERE `Id`="' + IntToStr(Id) + '"'); 182 if DbRows.Count = 1 then begin 183 Name := DbRows[0].Values['Name']; 184 FullName := DbRows[0].Values['FullName']; 185 Email := DbRows[0].Values['Email']; 186 end else raise ENotFound.Create(Format(SUserNotFound, [IntToStr(Id)])); 163 187 finally 164 188 DBRows.Free; -
trunk/Components/CoolWeb/WebServer/UWebApp.pas
r68 r69 27 27 TWebApp = class(TCustomApplication) 28 28 private 29 FOnBeforePageProduce: TOnProduceEvent; 29 30 FOnInitialize: TNotifyEvent; 30 31 FServerType: THTTPServerType; … … 42 43 constructor Create(AOwner: TComponent); override; 43 44 destructor Destroy; override; 45 property OnBeforePageProduce: TOnProduceEvent read FOnBeforePageProduce write FOnBeforePageProduce; 44 46 property OnInitialize: TNotifyEvent read FOnInitialize write FOnInitialize; 45 47 property ServerType: THTTPServerType read FServerType write SetServerType; … … 133 135 //Request.QueryParts[0] := 'uzivatel'; 134 136 //Request.QueryParts[1] := 'prihlaseni'; 137 if Assigned(FOnBeforePageProduce) then 138 FOnBeforePageProduce(HandlerData); 135 139 136 140 if Request.QueryParts.Count > 0 then PageName := Request.QueryParts[0] … … 172 176 hstdout := @stderr; 173 177 Writeln(hstdout^, 'An unhandled exception occurred: ' + E.Message + '<br>'); 174 WriteLn(hstdout^, StringReplace(DumpExceptionCallStack(E), LineEnding, '<br>', [rfReplaceAll]));178 WriteLn(hstdout^, DumpExceptionCallStack(E)); 175 179 end; 176 180 end;
Note:
See TracChangeset
for help on using the changeset viewer.