Authenticate the user when they sign-up or sign-in
This web-app must accomplish the following:
- Use the PostgreSQL database which stores the email and password of a user...
- Implement Devise gem to signup, sign in and log out users.
- Use the reCAPTCHA gem to verify that the user isn't a bot.
- After users sign up, Use rails' Action Mailer to send a welcome email.
- Show appropriate flash messages wherever necessary like new sign up, sign in, logout, etc.
- Show user sign-up count to both logged out and logged in users.
- Redirect logged-in user to the homepage if he tries to visit the log-in or signup page.
- Build a responsive site using bootstrap.
- When a user manually enters a URL that doesn't exist, redirect them to the homepage with a flash message informing them that the URL doesn't exist.
This project was built on Ruby version 2.7.2.
Following important gems were installed in these versions:
Gem Names | Gem | Version | Use |
---|---|---|---|
Rails | 'rails' | 6.1.4.1 | Use for executing and rendering web-app |
Postgresql | 'pg' | 1.2.3 | Use postgres as the database for Active Record |
Bootstrap | 'bootstrap-sass' | 3.4.1 | For SCSS Styling |
Devise | 'devise' | 4.8.0 | Flexible authentication solution |
reCAPTCHA | 'recaptcha' | 3.1.16 | Validate requests with the "I'm not a robot" checkbox |
If you don't have a user set on postgres, here's how to set new user:
sudo -u postgres createuser -s [username]
To set a password for this user, log in to the PostgreSQL command line client:
sudo -u postgres psql
Enter the following command to set the password:
\password your_password
Enter and confirm the password. Then exit the PostgreSQL client:
\q
Run the following commands to execute locally:
The following will install required version of ruby (make sure rvm is installed.)
rvm use 2.7.2
git clone git@github.com:JuzerShakir/rails-authenticate.git
cd rails-authenticate
bundle install
To successfully create development and test database, you will need to update config.database.yml
file with correct postgresql username and password.
To edit the it without exposing your credentials, give the following command:
EDITOR="code --wait" rails credentials:edit
code
for Visual Studio Code
subl
for sublime
This will open credential.yml
file and enter credential as follows in it:
database:
username: your_username
password: your_password
Hit ctrl + s
to save and then close the credential.yml
file from the editor. This will save the credentials. To check if it did save, run the following inside rails console:
Rails.application.credentials.dig(:database, :username)
rails db:create
Also .env
file has been added to .gitignore
file. You should create a similar file named .env
at the root of this directory and fill the following environment variables value with yours:
GMAIL_USERNAME = your_email
GMAIL_PASSWORD = your_password
RECAPTCHA_SITE_KEY = your_key
RECAPTCHA_SECRET_KEY = your_secret_key
rails s