1- using System ;
2- using System . Collections . Generic ;
3- using System . Linq ;
4- using System . Web ;
5- using System . Web . Security ;
6- using System . Web . UI ;
7- using System . Web . UI . WebControls ;
8-
9- using OSAE ;
10-
11- public partial class _Default : System . Web . UI . Page
12- {
13- protected void Page_Load ( object sender , EventArgs e )
14- {
15- if ( OSAEObjectManager . GetObjectsByType ( "PERSON" ) . Count == 0 )
1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Linq ;
4+ using System . Web ;
5+ using System . Web . Security ;
6+ using System . Web . UI ;
7+ using System . Web . UI . WebControls ;
8+
9+ using OSAE ;
10+
11+ public partial class _Default : System . Web . UI . Page
12+ {
13+ protected void Page_Load ( object sender , EventArgs e )
14+ {
15+ if ( OSAEObjectManager . GetObjectsByType ( "PERSON" ) . Count == 0 )
1616 Response . Redirect ( "~/firstrun.aspx" ) ;
17- txtUserName . Focus ( ) ;
18- }
19-
20- protected void imgSubmit_Click ( object sender , EventArgs e )
21- {
22- OSAEObject obj = OSAEObjectManager . GetObjectByName ( txtUserName . Text ) ;
23-
24- if ( obj != null )
25- {
26- string pass = obj . Property ( "Password" ) . Value ;
27- if ( pass == txtPassword . Text )
28- {
29- // Success, create non-persistent authentication cookie.
30- FormsAuthentication . SetAuthCookie (
17+ txtUserName . Focus ( ) ;
18+ }
19+
20+ protected void imgSubmit_Click ( object sender , EventArgs e )
21+ {
22+ OSAEObject obj = OSAEObjectManager . GetObjectByName ( txtUserName . Text ) ;
23+
24+ if ( obj != null )
25+ {
26+ string pass = obj . Property ( "Password" ) . Value ;
27+ if ( pass == txtPassword . Text )
28+ {
29+ // Success, create non-persistent authentication cookie.
30+ FormsAuthentication . SetAuthCookie (
3131 this . txtUserName . Text . Trim ( ) , false ) ;
32- Int32 cto = Convert . ToInt32 ( OSAEObjectPropertyManager . GetObjectPropertyValue ( "Web Server" , "Timeout" ) . Value ) ;
33- FormsAuthenticationTicket ticket1 = new FormsAuthenticationTicket ( this . txtUserName . Text . Trim ( ) , true , cto ) ;
34- HttpCookie cookie1 = new HttpCookie ( FormsAuthentication . FormsCookieName , FormsAuthentication . Encrypt ( ticket1 ) ) ;
35- Response . Cookies . Add ( cookie1 ) ;
36-
37- // 4. Do the redirect.
38- String returnUrl1 ;
39- // the login is successful
40- if ( Request . QueryString [ "ReturnUrl" ] == null )
41- {
42- returnUrl1 = "objects.aspx" ;
43- }
44-
45- //login not unsuccessful
46- else
47- {
48- returnUrl1 = Request . QueryString [ "ReturnUrl" ] ;
49- }
50-
51- Response . Redirect ( returnUrl1 ) ;
52- }
53- else
54- lblError . Visible = true ;
55-
56- }
57- lblError . Visible = true ;
58- }
32+ Int32 cto = Convert . ToInt32 ( OSAEObjectPropertyManager . GetObjectPropertyValue ( "Web Server" , "Timeout" ) . Value ) ;
33+ FormsAuthenticationTicket ticket1 = new FormsAuthenticationTicket ( this . txtUserName . Text . Trim ( ) , true , cto ) ;
34+ HttpCookie cookie1 = new HttpCookie ( FormsAuthentication . FormsCookieName , FormsAuthentication . Encrypt ( ticket1 ) ) ;
35+ Response . Cookies . Add ( cookie1 ) ;
36+
37+ // 4. Do the redirect.
38+ String returnUrl1 ;
39+ // the login is successful
40+ if ( Request . QueryString [ "ReturnUrl" ] == null )
41+ {
42+ returnUrl1 = "objects.aspx" ;
43+ }
44+
45+ //login not unsuccessful
46+ else
47+ {
48+ returnUrl1 = Request . QueryString [ "ReturnUrl" ] ;
49+ }
50+
51+ Response . Redirect ( returnUrl1 ) ;
52+ }
53+ else
54+ lblError . Visible = true ;
55+
56+ }
57+ lblError . Visible = true ;
58+ }
5959}
0 commit comments