Skip to content

Instantly share code, notes, and snippets.

View sandeshbodake's full-sized avatar
🚀
All set !!!

Sandesh sandeshbodake

🚀
All set !!!
View GitHub Profile
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def oktaoauth
# You need to implement the method below in your model (e.g. app/models/user.rb)
@user = User.from_omniauth(request.env["omniauth.auth"])
if @user.save
session[:oktastate] = request.env["omniauth.auth"]
else
print(@user.errors.full_messages)
end
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :omniauthable, omniauth_providers: [:oktaoauth]
def self.from_omniauth(auth)
User.find_or_create_by(email: auth["info"]["email"]) do |user|
user.provider = auth['provider']
user.uid = auth['uid']
user.email = auth['info']['email']
Rails.application.routes.draw do
get 'sessions/new'
get 'sessions/create'
get 'sessions/destroy'
get 'home/index'
# devise_for :users
devise_for :users, controllers: { omniauth_callbacks: 'users/omniauth_callbacks' }
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root to: "home#index"
OKTA_CLIENT_ID: "YOUR-CLIENT-ID"
OKTA_CLIENT_SECRET: "YOUR-CLIENT-SECRET"
OKTA_ORG: "YOUR-OKTA-ORG"
OKTA_DOMAIN: "oktapreview"
OKTA_URL: "YOUR-OKTA-ORG-URL"
OKTA_ISSUER: "YOUR-OKTA-ISSUER-URL"
OKTA_AUTH_SERVER_ID: "YOUR-AUTH-SERVER-ID"
OKTA_REDIRECT_URI: "http://localhost:3000/users/auth/oktaoauth/callback"
class HomeController < ApplicationController
before_action :user_is_logged_in?
def index
end
end
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
def user_is_logged_in?
if !session[:oktastate]
redirect_to user_oktaoauth_omniauth_authorize_path
end
end
end
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.3.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.4', '>= 5.2.4.2'
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
# Use Puma as the app server

Solr-Configuration

Configuration On server

1] cd /opt wget http://www.us.apache.org/dist/lucene/solr/5.3.1/solr-5.3.1.tgz

2] tar xzf solr-5.3.1.tgz solr-5.3.1/bin/install_solr_service.sh --strip-components=2

3] sudo ./install_solr_service.sh solr-5.3.1.tgz

4] vim /opt/solr/bin/solr and add following line SOLR_JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/"

Bootstrap 4

sidebar https://codepen.io/tio-jevero-the-styleful/pen/MdZQBo

React

Collapse https://codepen.io/kunukn/pen/ebMryW

require 'spec_helper'
RSpec.describe Employee do
it 'should creates an employee object' do
employee = Employee.new
expect(employee).to be_kind_of(Employee)
end
end