Git Product home page Git Product logo

authentication-workflow-object's Introduction

Overview

Project (learning purpose) to implement workflow object.

Specs

User Model
  is valid with username, password and password_confirmation
  is invalid without username
  is invalid without password
  is invalid with password_confirmation does't match

Authentication API
  User login
    when credentials valid
      return's token
    when credentials invalid
      return's error response

Dashboard API
  User visit dashboard page
    when auth header valid
      return success response
    when auth header empty
      return error response
    when auth header not include 'Bearer' text
      return error response
    when auth header have invalid format
      return error response
    when auth header have token that can't decoded
      return error response

Usage

Workflow object

# Login Features
@workflow = LoginWorkflow.new(username: "pquest", password: "secret")

@workflow.allow? # => true / false

@workflow.token # => "t0k4n" / nil 

@workflow.user # => <user> / nil

@workflow.error # => "Sorry, you're credentials is invalid" / nil

#  Dashboard Features
@workflow = DashboardWorkflow.new(auth_header: "Bearer your_token_here")

@workflow.allow? # => true / false

@workflow.user # => <user> / nil

@workflow.error # => "An error messages" / nil 

Service Object

# Token Service 
TokenService.encode(user_id: 1) # => "eyJhbGciOiJub25lIn0.eyJ1c2VyX2lkIjoxfQ." 

TokenService.decode("eyJhbGciOiJub25lIn0.eyJ1c2VyX2lkIjoxfQ.") # => payload / nil

TokenService.user("eyJhbGciOiJub25lIn0.eyJ1c2VyX2lkIjoxfQ.") # =>  <user> / nil

# AuthHederService 
auth_header = AuthHeaderService.new(auth_header: "Bearer eyJhbGciOiJub25lIn0.eyJ1c2VyX2lkIjoxfQ.")

auth_header.valid? # => true / false

auth_header.token # => eyJhbGciOiJub25lIn0.eyJ1c2VyX2lkIjoxfQ. 

License

Copyright 2018 Philip Lambok

authentication-workflow-object's People

Contributors

philiplambok avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.