Remove old authentication code (browser-id, github, twitter)
parent
7397e14a57
commit
feb9703620
@ -1,31 +0,0 @@
|
||||
$ ->
|
||||
$('#persona-button, #log-in').click (event) ->
|
||||
event.preventDefault()
|
||||
navigator.id.request {
|
||||
siteName: 'Asciinema',
|
||||
siteLogo: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAABlBMVEUAAAD///+l2Z/dAAAAAWJLR0QAiAUdSAAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wHGBMiFVqqanYAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVRo3u3KoQEAAAgDoP3/tBaD0WiATAJwVIsgCIIgCIIgCIIgCIIgCIIgCMKHADAafyL3ebnQxskAAAAASUVORK5CYII=',
|
||||
backgroundColor: '#06989a',
|
||||
privacyPolicy: 'https://asciinema.org/privacy',
|
||||
termsOfService: 'https://asciinema.org/tos'
|
||||
}
|
||||
|
||||
if window.browserIdUser
|
||||
$('header .logout').click (event) ->
|
||||
event.preventDefault()
|
||||
navigator.id.logout()
|
||||
|
||||
navigator.id.watch
|
||||
loggedInUser: window.browserIdUser
|
||||
|
||||
onlogin: (assertion) ->
|
||||
if assertion
|
||||
form = $(
|
||||
"<form action='/auth/browser_id/callback'>" +
|
||||
"<input type='hidden' name='assertion' value='#{assertion}' />"
|
||||
)
|
||||
|
||||
$('body').append form
|
||||
form.submit()
|
||||
|
||||
onlogout: ->
|
||||
window.location = '/logout'
|
@ -1,26 +0,0 @@
|
||||
class AccountMergesController < ApplicationController
|
||||
|
||||
def create
|
||||
user = find_user
|
||||
|
||||
if user
|
||||
user.update_attribute(:email, store.delete(:new_user_email))
|
||||
self.current_user = user
|
||||
redirect_back_or_to root_url, notice: 'Welcome back!'
|
||||
else
|
||||
redirect_to new_user_path,
|
||||
alert: 'Sorry, no account found. Try a different provider.'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def store
|
||||
session
|
||||
end
|
||||
|
||||
def find_user
|
||||
User.for_credentials(omniauth_credentials)
|
||||
end
|
||||
|
||||
end
|
@ -1,21 +0,0 @@
|
||||
class OmniAuthCredentials
|
||||
|
||||
attr_reader :omniauth_hash
|
||||
|
||||
def initialize(omniauth_hash)
|
||||
@omniauth_hash = omniauth_hash
|
||||
end
|
||||
|
||||
def provider
|
||||
omniauth_hash['provider']
|
||||
end
|
||||
|
||||
def uid
|
||||
omniauth_hash['uid']
|
||||
end
|
||||
|
||||
def email
|
||||
omniauth_hash['info'] && omniauth_hash['info']['email']
|
||||
end
|
||||
|
||||
end
|
@ -1,9 +0,0 @@
|
||||
Rails.application.config.middleware.use OmniAuth::Builder do
|
||||
provider :twitter, CFG.twitter_consumer_key, CFG.twitter_consumer_secret, :client_options => { :ssl => { :ca_path => "/etc/ssl/certs" } }
|
||||
provider :github, CFG.github_consumer_key, CFG.github_consumer_secret, :client_options => { :ssl => { :ca_path => "/etc/ssl/certs" } }
|
||||
provider :browser_id
|
||||
end
|
||||
|
||||
OmniAuth.config.on_failure = Proc.new { |env|
|
||||
OmniAuth::FailureEndpoint.new(env).redirect_to_failure
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe AccountMergesController do
|
||||
|
||||
describe '#create' do
|
||||
subject { get :create, provider: 'twitter' }
|
||||
|
||||
let(:credentials) { double('credentials') }
|
||||
let(:store) { {} }
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:omniauth_credentials) { credentials }
|
||||
allow(controller).to receive(:store) { store }
|
||||
allow(User).to receive(:for_credentials).with(credentials) { user }
|
||||
store[:new_user_email] = 'foo@bar.com'
|
||||
end
|
||||
|
||||
context "when user can be found for given credentials" do
|
||||
let(:user) { stub_model(User) }
|
||||
|
||||
before do
|
||||
allow(user).to receive(:update_attribute)
|
||||
allow(controller).to receive(:current_user=)
|
||||
|
||||
subject
|
||||
end
|
||||
|
||||
it 'updates the email on the user' do
|
||||
expect(user).to have_received(:update_attribute).
|
||||
with(:email, 'foo@bar.com')
|
||||
end
|
||||
|
||||
it 'removes the email from the store' do
|
||||
expect(store.key?(:new_user_email)).to be(false)
|
||||
end
|
||||
|
||||
it 'sets the current_user' do
|
||||
expect(controller).to have_received(:current_user=).with(user)
|
||||
end
|
||||
|
||||
it 'redirects to the root_path with a notice' do
|
||||
expect(flash[:notice]).to_not be_blank
|
||||
should redirect_to(root_path)
|
||||
end
|
||||
end
|
||||
|
||||
context "when user can't be found for given credentials" do
|
||||
let(:user) { nil }
|
||||
|
||||
before do
|
||||
subject
|
||||
end
|
||||
|
||||
it "doesn't remove the email from the store" do
|
||||
expect(store.key?(:new_user_email)).to be(true)
|
||||
end
|
||||
|
||||
it 'redirects to new user page with an alert' do
|
||||
expect(flash[:alert]).to_not be_blank
|
||||
should redirect_to(new_user_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -1,40 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe OmniAuthCredentials do
|
||||
|
||||
let(:credentials) { described_class.new(omniauth_hash) }
|
||||
|
||||
let(:omniauth_hash) { {
|
||||
'provider' => 'twitter',
|
||||
'uid' => '1234567',
|
||||
'info' => { 'email' => 'foo@bar.com' }
|
||||
} }
|
||||
|
||||
describe '#provider' do
|
||||
subject { credentials.provider }
|
||||
|
||||
it { should eq('twitter') }
|
||||
end
|
||||
|
||||
describe '#uid' do
|
||||
subject { credentials.uid }
|
||||
|
||||
it { should eq('1234567') }
|
||||
end
|
||||
|
||||
describe '#email' do
|
||||
subject { credentials.email }
|
||||
|
||||
it { should eq('foo@bar.com') }
|
||||
|
||||
context "when no info section in hash" do
|
||||
let(:omniauth_hash) { {
|
||||
'provider' => 'twitter',
|
||||
'uid' => '1234567'
|
||||
} }
|
||||
|
||||
it { should be(nil) }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -1,36 +1,4 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe ApplicationHelper do
|
||||
|
||||
describe '#browser_id_user' do
|
||||
let(:session) { {} }
|
||||
|
||||
subject { helper.browser_id_user }
|
||||
|
||||
before do
|
||||
allow(helper).to receive(:session) { session }
|
||||
allow(helper).to receive(:current_user) { user }
|
||||
end
|
||||
|
||||
context "when current_user is present" do
|
||||
let(:user) { double('user', email: 'foo@bar.com') }
|
||||
|
||||
it { should eq("'foo@bar.com'".html_safe) }
|
||||
end
|
||||
|
||||
context "when current_user isn't present" do
|
||||
let(:user) { nil }
|
||||
|
||||
it { should eq('null') }
|
||||
|
||||
context "when new_user_email is present in session" do
|
||||
before do
|
||||
session[:new_user_email] = 'qux@quux.com'
|
||||
end
|
||||
|
||||
it { should eq("'qux@quux.com'".html_safe) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 7.1 KiB |
File diff suppressed because one or more lines are too long
@ -1,376 +0,0 @@
|
||||
/*
|
||||
* Button Object
|
||||
*/
|
||||
|
||||
/*
|
||||
* 1. Corrects inability to style clickable 'input' types in iOS
|
||||
* 2. Remove excess padding in IE6/7
|
||||
* 3. IE6/7 inline-block hack for native block-level elements
|
||||
*/
|
||||
|
||||
.btn-auth {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
height: 22px;
|
||||
padding: 0 1em;
|
||||
border: 1px solid #999;
|
||||
border-radius: 2px;
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
line-height: 22px;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
color: #222;
|
||||
background: #fff;
|
||||
-webkit-box-sizing: content-box;
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
/* iOS */
|
||||
-webkit-appearance: none; /* 1 */
|
||||
/* IE6/7 hacks */
|
||||
*overflow: visible; /* 2 */
|
||||
*display: inline; /* 3 */
|
||||
*zoom: 1; /* 3 */
|
||||
}
|
||||
|
||||
.btn-auth:hover,
|
||||
.btn-auth:focus,
|
||||
.btn-auth:active {
|
||||
color: #222;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.btn-auth:before {
|
||||
content: "";
|
||||
float: left;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
background: image-url("auth-icons.png") no-repeat 99px 99px;
|
||||
}
|
||||
|
||||
/*
|
||||
* 36px
|
||||
*/
|
||||
|
||||
.btn-auth.large {
|
||||
height: 36px;
|
||||
line-height: 36px;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.btn-auth.large:before {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove excess padding and border in FF3+
|
||||
*/
|
||||
|
||||
.btn-auth::-moz-focus-inner {
|
||||
border: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
/* Facebook (extends .btn-auth)
|
||||
========================================================================== */
|
||||
|
||||
.btn-facebook {
|
||||
border-color: #29447e;
|
||||
border-bottom-color: #1a356e;
|
||||
color: #fff;
|
||||
background-color: #5872a7;
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#637bad), to(#5872a7));
|
||||
background-image: -webkit-linear-gradient(#637bad, #5872a7);
|
||||
background-image: -moz-linear-gradient(#637bad, #5872a7);
|
||||
background-image: -ms-linear-gradient(#637bad, #5872a7);
|
||||
background-image: -o-linear-gradient(#637bad, #5872a7);
|
||||
background-image: linear-gradient(#637bad, #5872a7);
|
||||
-webkit-box-shadow: inset 0 1px 0 #879ac0;
|
||||
box-shadow: inset 0 1px 0 #879ac0;
|
||||
}
|
||||
|
||||
.btn-facebook:hover,
|
||||
.btn-facebook:focus {
|
||||
color: #fff;
|
||||
background-color: #3b5998;
|
||||
}
|
||||
|
||||
.btn-facebook:active {
|
||||
color: #fff;
|
||||
background: #4f6aa3;
|
||||
-webkit-box-shadow: inset 0 1px 0 #45619d;
|
||||
box-shadow: inset 0 1px 0 #45619d;
|
||||
}
|
||||
|
||||
/*
|
||||
* Icon
|
||||
*/
|
||||
|
||||
.btn-facebook:before {
|
||||
border-right: 1px solid #465f94;
|
||||
margin: 0 1em 0 -1em;
|
||||
background-position: 0 0;
|
||||
}
|
||||
|
||||
.btn-facebook.large:before {
|
||||
background-position: 0 -22px;
|
||||
}
|
||||
|
||||
|
||||
/* GitHub
|
||||
========================================================================== */
|
||||
|
||||
.btn-github {
|
||||
border-color: #d4d4d4;
|
||||
background: #ececec;
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f4f4f4), to(#ececec));
|
||||
background-image: -webkit-linear-gradient(#f4f4f4, #ececec);
|
||||
background-image: -moz-linear-gradient(#f4f4f4, #ececec);
|
||||
background-image: -ms-linear-gradient(#f4f4f4, #ececec);
|
||||
background-image: -o-linear-gradient(#f4f4f4, #ececec);
|
||||
background-image: linear-gradient(#f4f4f4, #ececec);
|
||||
}
|
||||
|
||||
.btn-github:hover,
|
||||
.btn-github:focus {
|
||||
border-color: #518cc6;
|
||||
border-bottom-color: #2a65a0;
|
||||
color: #fff;
|
||||
background-color: #599bdc;
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#599bdc), to(#3072b3));
|
||||
background-image: -webkit-linear-gradient(#599bdc, #3072b3);
|
||||
background-image: -moz-linear-gradient(#599bdc, #3072b3);
|
||||
background-image: -ms-linear-gradient(#599bdc, #3072b3);
|
||||
background-image: -o-linear-gradient(#599bdc, #3072b3);
|
||||
background-image: linear-gradient(#599bdc, #3072b3);
|
||||
}
|
||||
|
||||
.btn-github:active {
|
||||
border-color: #2A65A0;
|
||||
border-bottom-color: #518CC6;
|
||||
color: #fff;
|
||||
background: #3072B3;
|
||||
background: -webkit-gradient(linear, 0 0, 0 100%, from(#3072b3), to(#599bdc));
|
||||
background: -webkit-linear-gradient(#3072b3, #599bdc);
|
||||
background: -moz-linear-gradient(#3072b3, #599bdc);
|
||||
background: -ms-linear-gradient(#3072b3, #599bdc);
|
||||
background: -o-linear-gradient(#3072b3, #599bdc);
|
||||
background: linear-gradient(#3072b3, #599bdc);
|
||||
}
|
||||
|
||||
/*
|
||||
* Icon
|
||||
*/
|
||||
|
||||
.btn-github:before {
|
||||
margin: 0 0.6em 0 -0.6em;
|
||||
background-position: -44px 0;
|
||||
}
|
||||
|
||||
.btn-github:hover:before,
|
||||
.btn-github:focus:before,
|
||||
.btn-github:active:before {
|
||||
background-position: -66px 0;
|
||||
}
|
||||
|
||||
.btn-github.large:before {
|
||||
background-position: -72px -22px;
|
||||
}
|
||||
|
||||
.btn-github.large:hover:before,
|
||||
.btn-github.large:focus:before,
|
||||
.btn-github.large:active:before {
|
||||
background-position: -108px -22px;
|
||||
}
|
||||
|
||||
|
||||
/* Google
|
||||
========================================================================== */
|
||||
|
||||
.btn-google {
|
||||
border-color: #3079ed;
|
||||
color: #fff;
|
||||
background: #4787ed;
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#4d90fe), to(#4787ed));
|
||||
background-image: -webkit-linear-gradient(#4d90fe, #4787ed);
|
||||
background-image: -moz-linear-gradient(#4d90fe, #4787ed);
|
||||
background-image: -ms-linear-gradient(#4d90fe, #4787ed);
|
||||
background-image: -o-linear-gradient(#4d90fe, #4787ed);
|
||||
background-image: linear-gradient(#4d90fe, #4787ed);
|
||||
}
|
||||
|
||||
.btn-google:hover,
|
||||
.btn-google:focus,
|
||||
.btn-google:active {
|
||||
color: #fff;
|
||||
background-color: #357ae8;
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#4d90fe), to(#357ae8));
|
||||
background-image: -webkit-linear-gradient(#4d90fe, #357ae8);
|
||||
background-image: -moz-linear-gradient(#4d90fe, #357ae8);
|
||||
background-image: -ms-linear-gradient(#4d90fe, #357ae8);
|
||||
background-image: -o-linear-gradient(#4d90fe, #357ae8);
|
||||
background-image: linear-gradient(#4d90fe, #357ae8);
|
||||
}
|
||||
|
||||
.btn-google:active {
|
||||
-webkit-box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
|
||||
box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
|
||||
}
|
||||
|
||||
/*
|
||||
* Icon
|
||||
*/
|
||||
|
||||
.btn-google:before {
|
||||
margin: 0 1em 0 -1em;
|
||||
background-position: -88px 0;
|
||||
background-color: #e6e6e6;
|
||||
}
|
||||
|
||||
.btn-google.large:before {
|
||||
background-position: -144px -22px;
|
||||
}
|
||||
|
||||
|
||||
/* Open ID
|
||||
========================================================================== */
|
||||
|
||||
.btn-openid:hover,
|
||||
.btn-openid:focus {
|
||||
border-color: #777;
|
||||
background: #fcfcfc;
|
||||
}
|
||||
|
||||
.btn-openid:active {
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
/*
|
||||
* Icon
|
||||
*/
|
||||
|
||||
.btn-openid:before {
|
||||
margin: 0 0.6em 0 -0.6em;
|
||||
background-position: -154px 0;
|
||||
}
|
||||
|
||||
.btn-openid.large:before {
|
||||
background-position: -252px -22px;
|
||||
}
|
||||
|
||||
|
||||
/* Twitter
|
||||
========================================================================== */
|
||||
|
||||
.btn-twitter {
|
||||
border-color: #a6cde6;
|
||||
color: #327695;
|
||||
background: #cfe4f0;
|
||||
/* css3 */
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f1f5f7), to(rgba(255,255,255,0)));
|
||||
background-image: -webkit-linear-gradient(#f1f5f7, rgba(255,255,255,0));
|
||||
background-image: -moz-linear-gradient(#f1f5f7, rgba(255,255,255,0));
|
||||
background-image: -ms-linear-gradient(#f1f5f7, rgba(255,255,255,0));
|
||||
background-image: -o-linear-gradient(#f1f5f7, rgba(255,255,255,0));
|
||||
background-image: linear-gradient(#f1f5f7, rgba(255,255,255,0));
|
||||
-webkit-box-shadow: inset 0 1px 0 #fff;
|
||||
box-shadow: inset 0 1px 0 #fff;
|
||||
}
|
||||
|
||||
.btn-twitter:hover,
|
||||
.btn-twitter:focus,
|
||||
.btn-twitter:active {
|
||||
color: #327695;
|
||||
border-color: #8dc2e4;
|
||||
background-color: #cadde9;
|
||||
}
|
||||
|
||||
.btn-twitter:active {
|
||||
background: #cadde9;
|
||||
-webkit-box-shadow: inset 0 1px 0 #bbd6e7;
|
||||
box-shadow: inset 0 1px 0 #bbd6e7;
|
||||
}
|
||||
|
||||
/*
|
||||
* Icon
|
||||
*/
|
||||
|
||||
.btn-twitter:before {
|
||||
margin: 0 0.6em 0 -0.6em;
|
||||
background-position: -22px 0;
|
||||
}
|
||||
|
||||
.btn-twitter.large:before {
|
||||
background-position: -36px -22px;
|
||||
}
|
||||
|
||||
|
||||
/* Windows Live ID
|
||||
========================================================================== */
|
||||
|
||||
.btn-windows:hover,
|
||||
.btn-windows:focus {
|
||||
border-color: #777;
|
||||
background: #fcfcfc;
|
||||
}
|
||||
|
||||
.btn-windows:active {
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
/*
|
||||
* Icon
|
||||
*/
|
||||
|
||||
.btn-windows:before {
|
||||
margin: 0 0.6em 0 -0.6em;
|
||||
background-position: -110px 0;
|
||||
}
|
||||
|
||||
.btn-windows.large:before {
|
||||
background-position: -180px -22px;
|
||||
}
|
||||
|
||||
|
||||
/* Yahoo!
|
||||
========================================================================== */
|
||||
|
||||
.btn-yahoo {
|
||||
border-color: #ffb305;
|
||||
background: #ffc426;
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(rgba(255,255,255,0.5)), to(rgba(255,255,255,0)));
|
||||
background-image: -webkit-linear-gradient(rgba(255,255,255,0.5), rgba(255,255,255,0));
|
||||
background-image: -moz-linear-gradient(rgba(255,255,255,0.5), rgba(255,255,255,0));
|
||||
background-image: -ms-linear-gradient(rgba(255,255,255,0.5), rgba(255,255,255,0));
|
||||
background-image: -o-linear-gradient(rgba(255,255,255,0.5), rgba(255,255,255,0));
|
||||
background-image: linear-gradient(rgba(255,255,255,0.5), rgba(255,255,255,0));
|
||||
}
|
||||
|
||||
.btn-yahoo:hover,
|
||||
.btn-yahoo:focus {
|
||||
background-color: #fabf20;
|
||||
}
|
||||
|
||||
.btn-yahoo:active {
|
||||
border-color: #f09700;
|
||||
background-image: none;
|
||||
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.3);
|
||||
box-shadow: inset 0 1px 1px rgba(0,0,0,0.3);
|
||||
}
|
||||
|
||||
/*
|
||||
* Icon
|
||||
*/
|
||||
|
||||
.btn-yahoo:before {
|
||||
margin: 0 0.6em 0 -0.6em;
|
||||
background-position: -132px 0;
|
||||
}
|
||||
|
||||
.btn-yahoo.large:before {
|
||||
background-position: -216px -22px;
|
||||
}
|
Loading…
Reference in New Issue