marirs / happy-cobra

A Flask based Login & Registration System using the Flask-Security

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Happy Cobra

Happy Cobra is a basic skeleton for Login & Registration system using the Flask-Security. The features in this skeleton include:

  1. Home page

    • Register a user
    • Login a user
    • Forgot Password
    • Reconfirm User
  2. Register: New Users registration

    • Email
    • First Name
    • Last Name
    • Password
      After Registration process is done, a confirmation email is sent to the users email id to confirm.
    • Confirmation Link will be valid for only 1 day (configurable)
  3. Login: Login a user

    • Email (as userid)
    • Pass
    • Track User details after login (browser, ip, geolocation, etc)
  4. Password Recovery:
    Password reset and recovery, when a user forgets his or her password.

    • Reset Password link expires within 1 day (configurable)
  5. Logout:

    • Logout when user clicks Logout

Since this is a skeleton, it can be included in any bigger projects.


Requirements

  1. Python 2.7
  2. PIP Requirements
  3. PostgreSQL/MySQL/SQLite (depending on your environment)
  4. A working SMTP Mail Server (Sendgrid, or anything like.)

Deployment

Deployment steps

Setting up the virtual environment

If you are using python 3.x

mkvirtualenv --python=`which python3` venv_name
cd /path/to/happycobra/
setvirtualenvproject

If you are using python 2.7

mkvirtualenv --python=`which python` venv_name
cd /path/to/happycobra/
setvirtualenvproject

Installing the pip requirements

pip install -r requirements

Environment

  • Unix/OSx
export FLASK_APP=app/__init__.py
export WORKING_ENVIRONMENT='production'
export FLASK_DEBUG=0
  • Windows
set FLASK_APP=app/__init__.py
set WORKING_ENVIRONMENT='production'
set FLASK_DEBUG=0

if it's development then use WORKING_ENVIRONMENT='development'

Setting up PostgresSQL

psql

CREATE DATABASE adbname ENCODING 'UTF-8';
CREATE USER appuser WITH PASSWORD 'AC0mp13XPa55w0rd';
GRANT ALL PRIVILEGES ON DATABASE adbname to appuser;

Available Flask commands
flask --help

Commands:
  create_roles  Create default roles
  create_super  Create superuser
  db            Perform database migrations.
  roles         Role commands.
  routes        Show the routes for the app.
  run           Runs a development server.
  shell         Runs a shell in the app context.
  users         User commands.

DB Init & Migrations

flask db init
flask db migrate
flask db upgrade

Creating the super user

flask create_super FirstName LastName Email@Adddress

Creating a new user

flask users create UserEmail --password PWD --active

Creating default Roles

flask create_roles

Creating New Roles

flask roles create RoleName -d "Role Description"

Adding Role to a User

flask roles add USER ROLE

Running the app

flask run

Accessing the app

http://localhost:5000

Licensing:

  • MIT License

Credits:

  • bootstrap
  • ShardsAdmin by Design Revision

About

A Flask based Login & Registration System using the Flask-Security

License:MIT License


Languages

Language:CSS 95.7%Language:Python 1.8%Language:HTML 1.7%Language:JavaScript 0.8%