Skip to content

Instantly share code, notes, and snippets.

{
"node": true,
"browser": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 4,

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

@mike-casas
mike-casas / form_user.rb
Created April 3, 2016 03:27
Happy_seed omniauth with devise
class FormUser < User
attr_accessor :current_password
validates_presence_of :email, if: :email_required?
validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
validates_format_of :email, with: Devise.email_regexp, allow_blank: true, if: :email_changed?
validates_presence_of :password, if: :password_required?
validates_confirmation_of :password, if: :password_required?
validates_length_of :password, within: Devise.password_length, allow_blank: true
var _self = {};
_self.find_rule= function(param){
return new Promise(function(resolve, reject){
var template=[];
async.each(data, function(value) {
async.forEachOf(value.templates, function (rule, key) {
if(rule.id== param){
template.push({"categoryName": value.name, rule});
}
@mike-casas
mike-casas / .eslintrc
Created May 20, 2016 06:39
eslint-jsx-example
{
"rules": {
"indent": [
2,
2
],
"quotes": [
2,
"single"
],
var Col = require('react-bootstrap/lib/Col')
var PageHeader = require('react-bootstrap/lib/PageHeader')
var React = require('react')
var Row = require('react-bootstrap/lib/Row')
var {connect} = require('react-redux')
var {reduxForm} = require('redux-form')
var DateInput = require('./DateInput')
var FormField = require('./FormField')
var LoadingButton = require('./LoadingButton')
import React from 'react';
import Header from '../../components/Header';
import Footer from '../../components/Footer';
import Spinner from '../../components/Spinner';
function App(props) {
return (
<div id="application">
<Header />
<div className="site-content">{props.children}</div>
@mike-casas
mike-casas / Operaciones-Git
Last active October 15, 2016 16:09 — forked from jelcaf/Operaciones-Git
Git Tips - Mini-trucos de Git para facilitarme la tarea
################################################
# Delete local tags.
git tag -l | xargs git tag -d
# Fetch remote tags.
git fetch
# Delete remote tags.
git tag -l | xargs -n 1 git push --delete origin
# Delete local tasg.
git tag -l | xargs git tag -d
@mike-casas
mike-casas / keywords_text.rb
Created October 6, 2016 02:34
plugins keywords_text ruby
f = open("./keywords.txt")
$smartlist = []
f.each_line { |line| $smartlist.push line.strip }
f.close
module Jekyll
module KeywordsText
def keywords_text(text)
@arr=[]
$smartlist.map { |word|
@mike-casas
mike-casas / install-nvm-zsh.txt
Last active March 14, 2024 20:40
install nvm on mac with zsh shell
After install zsh
- brew update
- brew install nvm
- mkdir ~/.nvm
after in your ~/.zshrc or in .bash_profile if your use bash shell:
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh