GithubHelp home page GithubHelp logo

00mjk / lock-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from charlotte-ruby/lock

0.0 0.0 0.0 185 KB

Simple plugin that allows you to lock all or part of your app with a single password. Useful for hiding new features that are being beta tested

License: MIT License

Ruby 81.33% HTML 18.19% Shell 0.41% CSS 0.08%

lock-1's Introduction

Lock Logo

Lock

Ruby

A simple Rails Engine that lets you lock down controllers, specific actions or an entire site with a password. This engine is useful for locking down new features or your entire site in production while your app is being beta tested. This is not a full-blown user authentication engine, nor is it intended to be.

Install the gem

Add to your Gemfile

bundle add 'lock'

Install with bundler

bundle install

Generate password file

The following command will generate /config/lock_password, which contains an encrypted password. Lock uses this for authentication

rails g lock:create_password_file yourpasswordhere

Lock your app

You lock your app in the ApplicationController (/app/controllers/application_controller.rb).

If you want to lock your entire app use this:

ApplicationController < ActionController::Base
  lock
end

If you want to lock specific actions inside the widgets_controller use this:

ApplicationController < ActionController::Base
  lock actions: ["widgets#new", "widgets#index"]
end

If you want to lock all actions in a controller, you can just leave off the # sign and action name. The following will lock all actions in the widgets_controller

ApplicationController < ActionController::Base
  lock actions: ["widgets"]
end

Unlock your app

  1. Use the lock login url - /lock/login
  2. Type in your password (from the generator) and press unlock

Override the views

You may want to customize the views to fit your app. The easiest way to achieve this is to create the lock views directory - /app/views/lock, and add your own view files. The views should be named:

/app/views/lock/refused.html.erb  #message shown to users when they access a locked page
/app/views/lock/login.html.erb    #login form
/app/views/lock/unlock.html.erb   #shows a confirmation message after you unlock it

If you choose to override the login page, you will need to create a form that posts to /lock/unlock and uses a password field named "password".

By default, these views will render inside your default layout. To create a custom layout for these files, just add /app/views/layouts/lock.html.erb The layout must contain a yield.

Contributing to lock

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. Patches without tests will be ignored
  • Please try not to mess with the Rakefile, version, or history.

Copyright

Copyright (c) 2011-2022 cowboycoded and the Charlotte Ruby User Group. See LICENSE.txt for further details.

lock-1's People

Contributors

dependabot[bot] avatar invalidusrname avatar johnmcaliley 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.