Git Product home page Git Product logo

addressor's Introduction

Task

Project:

Use devise to create a simple authentication process (use of default devise templates allowed). A user should not have to confirm his email address. He will be allowed to login right after signup. After login, the user should get redirected to "/my_address". On view, a new address is assigned to the user. A button gives the possibility to assign a new address from the address pool to the user.

Definitions:

Address: Random 34 characters, digits, uppercase, lowercase. Uppercase letter "O", uppercase letter "I", lowercase letter "l", and the number "0" are excluded! Address Pool: Holds 10 addresses, generates new addresses through cronjob (use gem) every 12 minutes.

Features:

If the address pool runs out of addresses and the user tries to generate a new one, a message should be shown: "Address Pool empty, please try again in x Minutes" where x is the value of the remaining time when the cronjob will run again. Integrate a JWT authentication so that a user can view and generate a new address via API. Write a short description how to call the api endpoint.

API example

Login first:

curl -X POST localhost:3000/api/login -u "[email protected]:123456"

result: {"auth_token":"eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJleHAiOjE1NDA0NTU5MzV9.XN6xBrwqMXyRm78bdEw4Eu-FEzmDWNu_FGFPPCOA3yk"}

It return "auth_token", pass in rest calls. Note: token will be valid within 1 day.

Get address for current user:

curl -X GET localhost:3000/api/my_address -u "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJleHAiOjE1NDA0NTU5MzV9.XN6xBrwqMXyRm78bdEw4Eu-FEzmDWNu_FGFPPCOA3yk:"

result: {"id":1,"address":"CjqFGZoccmKFg9nTB95hzmRvWguTdyLWeV"}

Update address from pool:

curl -X POST localhost:3000/api/addresses -u "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJleHAiOjE1NDA0NTU5MzV9.XN6xBrwqMXyRm78bdEw4Eu-FEzmDWNu_FGFPPCOA3yk:"

result: {"error":"Address Pool empty, please try again in 1 Minutes and 22 Seconds"}

addressor's People

Contributors

kkdoo avatar

Watchers

 avatar James Cloos 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.