Changeset 69 for trunk/Pages/UUserControlPage.pas
- Timestamp:
- Dec 30, 2011, 6:00:53 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Pages/UUserControlPage.pas
r68 r69 18 18 procedure HandleLogin(HandlerData: THTTPHandlerData); 19 19 procedure HandleRegistration(HandlerData: THTTPHandlerData); 20 procedure HandleLogout(HandlerData: THTTPHandlerData); 21 procedure HandleProfile(HandlerData: THTTPHandlerData); 20 22 public 21 23 { public declarations } … … 30 32 31 33 uses 32 UMainModule, UCore ;34 UMainModule, UCore, UUser; 33 35 34 36 { TUserControlPage } … … 45 47 with MainModule, HtmlDocument.Body do begin 46 48 if PageName = '' then PageName := 'prihlaseni'; 47 if PageName = 'prihlaseni' then begin 48 HandleLogin(HandlerData); 49 end else 50 if PageName = 'registrace' then begin 51 HandleRegistration(HandlerData); 52 end; 49 if PageName = 'prihlaseni' then HandleLogin(HandlerData) 50 else if PageName = 'registrace' then HandleRegistration(HandlerData) 51 else if PageName = 'odhlaseni' then HandleLogout(HandlerData) 52 else if PageName = 'profil' then HandleProfile(HandlerData); 53 53 end; 54 54 MainModule.GeneratePage(HandlerData, Self); … … 58 58 var 59 59 Form: TQueryForm; 60 UserId: Integer; 60 61 begin 61 62 with MainModule, HtmlDocument.Body do begin … … 69 70 with AddNewItem do begin 70 71 Caption := 'Jméno'; 71 Name := ' Name';72 Name := 'UserName'; 72 73 Hint := 'Zadejte vaše přihlašovací jméno'; 73 74 Required := True; … … 89 90 Form.Load(HandlerData.Request.Post); 90 91 with THtmlString(SubItems.AddNew(THtmlString.Create)) do 91 Text := 'Přihlášení user: ' + TQueryFormItem(TQueryFormGroup(Form.Groups[0]).Rows[0]).Value.Value; 92 Text := 'Přihlášení user: ' + TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value; 93 UserId := MainModule.User.GetIdByNamePassword(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value, 94 TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Password').Value.Value); 95 UserOnline.Login(UserId); 92 96 Form.Free; 93 97 end else … … 97 101 98 102 procedure TUserControlPage.HandleRegistration(HandlerData: THTTPHandlerData); 103 var 104 Form: TQueryForm; 105 UserId: Integer; 99 106 begin 100 107 with MainModule, HtmlDocument.Body do begin 101 with TQueryForm(SubItems.AddNew(TQueryForm.Create)) do begin 108 Form := TQueryForm.Create; 109 with Form do begin 102 110 Title := 'Registrace nového účtu'; 103 111 ClassId := 'WideTable'; … … 106 114 with AddNewItem do begin 107 115 Caption := 'Jméno'; 108 Name := ' Name';116 Name := 'UserName'; 109 117 Hint := 'Zadejte vaše přihlašovací jméno'; 110 118 Required := True; … … 136 144 end; 137 145 end; 146 if HandlerData.Request.Post.IndexOfName('Register') <> -1 then 147 with HandlerData.Request do begin 148 Form.Load(HandlerData.Request.Post); 149 with THtmlString(SubItems.AddNew(THtmlString.Create)) do 150 Text := 'Registrace uživatele: ' + TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value; 151 MainModule.User.Add(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value, 152 TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Password').Value.Value, 153 TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Email').Value.Value); 154 UserId := MainModule.User.GetIdByNamePassword(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value, 155 TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Password').Value.Value); 156 MainModule.UserOnline.Login(UserId); 157 Form.Free; 158 end else SubItems.AddNew(Form); 138 159 end; 160 end; 161 162 procedure TUserControlPage.HandleLogout(HandlerData: THTTPHandlerData); 163 begin 164 with MainModule, HtmlDocument.Body do begin 165 UserOnline.Logout; 166 with THtmlString(SubItems.AddNew(THtmlString.Create)) do 167 Text := 'Uživatel odhlášen'; 168 end; 169 end; 170 171 procedure TUserControlPage.HandleProfile(HandlerData: THTTPHandlerData); 172 begin 173 139 174 end; 140 175
Note:
See TracChangeset
for help on using the changeset viewer.