login_app 0.1.2

A generic login module for web apps
Documentation
# Login Module / Template
A login module, intended to use as a _template_, for web applications, that requires user to **sign in**/**sign up**.  **SQLite** database is used to store registration data. **Cookie** is used for _Session_ management. **MSMTP**, a SMTP Client, is used to send emails; its quick setup guide can be found in **msmtp.md** file.

# Goals
Developing with the following goals in mind:

1. Learn Rust language
2. Re-usable code for _Login_
3. Codes to cover login related features, forms, or screens, such as:  
    a. Registration form  
    b. Send a time bound **Token**, to registered email, to confirm registration  
    c. Registration-confirmation screen to enter _token_ value  
    d. Login form  
    e. Forgot password form  
    f. Send a time bound token, to registered email, to confirm _forgot password_ request  
    g. Password reset form  
    h. A home page (index page), that shows: Login, Logout, or Cancellation  

# Pre-requisite
1. Rust installation  
2. MSMTP client installation  

# How to use it
1. Clone or download this app  
2. Edit **Settings.toml** file to update names of database folder, log folder, email server details, ip address, etc.  
3. Build an executable file using: **$Cargo build --release**.  
4. Copy the following files/folder into a separate folder say "~/projects":  
    a. _target_/_release_/_login_-_app_ file  
    b. _template_ folder  
    c. two toml files: _Settings.toml_ and _Messages.toml_.  
5. Edit **login_app.service** for folder names and follow instructions in it to run this app as a service in linux.  
6. Assuming entries in _Settings.toml_ file for ip-address and port as _127.0.0.1_ and _6000_, open the web browser and enter url as http://127.0.0.1:6000.  
7. Browser then shows a home page with _Login_ | _Registration_ links in it...  
8. Click on _Registration_ link to go to Registration page.  
9. Registration page shows fields such as email, password, and repeat-password. Fill them and submit; on submitting them, a confirmation page opens up.  
10. Get a copy of token sent to email OR in case of development environment, goto **DB Browser for SQLite** (assuming it is already installed in linux machine)...open the database file, which is most likely named as **login_app.db** under _/login_app/database_ folder, open _app_user_ table and locate an entry in it, copy data under _token_ field in it. Paste this data into confirmation page.  
11. There is a time limit to enter the token, say **60 seconds**, which is customizable in __Settings.toml__ file.  
12. On expiry of the time limit, the registration data is deleted from the database. 
13. On successfully entering the token value, the registration is confirmed.   
14. Go to Login page and try to login with the credentials.  
15. On successful login, an index page is shown, with user __email id__ , __logout__ and _Cancellation_ links
16. In case of error in login credentials, it remains in login screen, displaying **Invalid credentials!**  
17. In case of forgotten password, go to Login page, click link on _Forgot Password?_.  
18. Enter email-id in the forgot-password form.  
19. On submitting this request, an email is sent with a token.  Copy it into next screen that looks for it to confirm the request.  
20. On confirming the request with token, a _Reset-Password_ form appears. Enter new password and submit.  Now try to login with new password.  
  
# Demo  
A demo application can be found at the following link:  
[LoginApp Demo](http://login_app.eastgate.in)  

# Tools  
In case of running multiple web applications on different ports, a traffic router can be used.  Please refer _https://github.com/mohankumaranna/traffic_router_  

# License  
MIT