顯示包含「Workshop 6」標籤的文章。顯示所有文章
顯示包含「Workshop 6」標籤的文章。顯示所有文章

5/15/2009

Workshop 6 -part 3

C. Set up a session in OTBS.
C1. Add session-check function in OTBS with following code. (See figure 1 to 4.)
If Session[:uid] is true, the system will display the corresponding page info;
If Session[:uid] is false, the system will request user to login.


Figure 1. Passenger's index.rhtml page

Figure 2. Passenger's new.rhtml page.

Figure 3. Passenger's show.rhtml page

Figure 4. Passenger's edit.rhtml page.

C2. Check the session of OTBS.

i.) If you directly access the passenger's index/new/edit page, it will requests user to login. (see video 1.)

Workshop 6 -part 2

To D0 - part2.
B. Create login page
B1. Create a controller named checkauth for handling some events, for example, logout, session timeout, logged-in redirection(see figure 1.)


Figure 1.
B2. Edit the checkauth controller with the following code (see figure 2.)
i.) pass_login method is used when the user login information has been verified.
ii.) logout method is used when the user logs out the system.
iii.) check_auth is used when the session is invaild.


Figure 2.


B3. Create a method name login in the user controller with following code. (see figure 3.)
The login method mainly is doing:
i.) Collect value of the variable named "login" and "password".
ii.)Check the user name and password whether is vaild, if it is correct, redirect to passengers' index page, if it is incorrect, prompt out an error message.


Figure 3.

B4. Create a user view named register.rhtml with following code. (see figure 4.)

Figure 4.


B5. Restart the TaxiApp project and navigate to login page. (see figure 5.)


Figure 5.

B6. Test login page

i.) Input a wrong login info. (see figure 6.)

Figure 6.


ii.) Input a correct login information. (see figure 7.)

Figure 7.

iii.) Click the link named "Register here". (see figure 8.)


Figure 8.

5/13/2009

Workshop 6-part 1

To do -Part 1

Developers may continue to build upon work with the OTBS using the topic reading to help with user registration and advanced login features from Hartl et al (2008).
  • generate a controller and an action by adding a method(s) to a controller.
  • create a view template for each action and to link to actions from views.
  • use AJAX to improve the user experience.

A. OTBS Registration.
A1. Create a model named user. (See figure 1).

Figure 1.

A2. Edit the file named 002_create_users file for auto generating table by rake migrate (see figure 2.)

Figure 2.

A3. Generate the user table (See figure 3.)

Figure 3.


A4. Create controller name user. (See figure 4.)

Figure 4.

A5. Edit the user controller (See figure 5), use AJAX methods- flash[:info] to show the registration result.
Figure 5.

A6. Add validation in user model (See figure 6.)

Figure 6.

A7. Create a view page named register.rhtml with following code. (See figure 7.)

Use AJAX method - "form_tag(:action => 'register') do" and "submit_tag" for performing the form subumition.

Figure 7.

A8. Restart the taxiapp project and use brower to navigate at http://localhost:3000/user/register (See figure 8.)

Figure 8.

A9. Test the registration page.

a.) Input a null value.


b.) Complete the registration form and click Register button.

c.) Input the created account in the login field..it returns error because that user has already created..

A10. Use MYSQL query browser to check the user named wilson whether is created.

Yes, the account named wilson and his information has already stored in the database.

A11. Add the link which is used to go back to the login page.