-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #371 from fablabbcn/monolith
Monolith Part 1: Incorporate id.sc functionality into the app and decommision.
- Loading branch information
Showing
37 changed files
with
590 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
//= link_tree ../images | ||
//= link_directory ../javascripts .js | ||
//= link_directory ../stylesheets .css |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// This is a manifest file that'll be compiled into application.js, which will include all the files | ||
// listed below. | ||
// | ||
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, | ||
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. | ||
// | ||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the | ||
// compiled file. | ||
// | ||
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details | ||
// about supported directives. | ||
// | ||
//= require jquery | ||
//= require jquery_ujs | ||
//= require turbolinks | ||
//= require_tree . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* This is a manifest file that'll be compiled into application.css, which will include all the files | ||
* listed below. | ||
* | ||
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, | ||
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. | ||
* | ||
* You're free to add application-wide styles to this file and they'll appear at the bottom of the | ||
* compiled file so the styles you add here take precedence over styles defined in any styles | ||
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new | ||
* file per style scope. | ||
* | ||
*= require_tree . | ||
*= require_self | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Place all the styles related to the sessions controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ | ||
$blue: #0C2EFB; | ||
$black: #212121; | ||
$grey: #E3E3E3; | ||
$red: #FA5161; | ||
|
||
@import url('https://fonts.googleapis.com/css?family=Roboto+Condensed:400,300,300italic,400italic,700,700italic|Roboto:400,700,700italic,400italic'); | ||
@import url('https://fonts.googleapis.com/css?family=Kanit:400,500,600,700,900'); | ||
|
||
*{ | ||
font-family:'Kanit'; | ||
} | ||
body{ | ||
background-color: #e3e3e3; | ||
} | ||
h1{ | ||
font-weight:700 !important; | ||
} | ||
.button { | ||
border: none; | ||
color: white; | ||
padding: 15px 32px; | ||
text-align: center; | ||
text-decoration: none; | ||
display: inline-block; | ||
font-size: 18px; | ||
} | ||
.bg-blue{ | ||
background-color: $blue !important; | ||
} | ||
|
||
.button:hover{ | ||
cursor: pointer; | ||
color: white; | ||
text-decoration:underline; | ||
} | ||
|
||
.bg-red{ | ||
background-color: $red; | ||
} | ||
.color-red{ | ||
color: $red; | ||
} | ||
|
||
input[type=text],input[type=password] { | ||
padding:7px; | ||
border:none; | ||
border-bottom:2px solid #BEBEBE; | ||
} | ||
|
||
#flash_notice{ | ||
padding:20px; | ||
color: white; | ||
background-color: $blue; | ||
} | ||
|
||
#flash_alert{ | ||
padding:20px; | ||
color: white; | ||
background-color: $red; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
# this file is required for errbit notifier | ||
class ApplicationController < ActionController::API | ||
include ActionController::ImplicitRender | ||
include ActionController::Helpers | ||
class ApplicationController < ActionController::Base | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
class DiscourseController < ApplicationController | ||
include SharedControllerMethods | ||
|
||
DISCOURSE_SSO_SECRET = ENV.fetch("discourse_sso_secret") | ||
DISCOURSE_ENDPOINT = ENV.fetch("discourse_endpoint") | ||
def sso | ||
if !current_user | ||
session[:discourse_url] = request.url | ||
redirect_to new_ui_session_path(goto: request.path), notice: 'Please Log In before using SSO' | ||
return | ||
end | ||
secret = DISCOURSE_SSO_SECRET | ||
sso = SingleSignOn.parse(request.query_string, secret) | ||
sso.email = current_user.email # from devise | ||
#sso.name = current_user.full_name # this is a custom method on the User class | ||
sso.username = current_user.email # from devise | ||
#sso.username = current_user.username | ||
sso.external_id = current_user.id # from devise | ||
sso.sso_secret = secret | ||
|
||
redirect_to sso.to_url("#{DISCOURSE_ENDPOINT}session/sso_login") | ||
rescue => e | ||
Rails.logger.error(e.message) | ||
Rails.logger.error(e.backtrace) | ||
#flash[:error] = 'SSO error' | ||
render inline: "Error, check logs" | ||
|
||
#redirect_to "/" | ||
#redirect_to root | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module SharedControllerMethods | ||
|
||
include Pundit::Authorization | ||
|
||
def self.included(klass) | ||
klass.helper_method :current_user | ||
end | ||
|
||
def current_user(fail_unauthorized=true) | ||
if @current_user.nil? | ||
if session[:user_id] | ||
@current_user = User.find(session[:user_id]) | ||
elsif doorkeeper_token | ||
# return render text: 'abc' | ||
@current_user = User.find(doorkeeper_token.resource_owner_id) | ||
elsif ActionController::HttpAuthentication::Basic.has_basic_credentials?(request) # username and password | ||
authenticate_with_http_basic do |username, password| | ||
if user = User.find_by(username: username) and user.authenticate_with_legacy_support(password) | ||
@current_user = user | ||
elsif fail_unauthorized | ||
self.headers["WWW-Authenticate"] = %(Basic realm="Application", Token realm="Application") | ||
raise Smartcitizen::Unauthorized.new "Invalid Username/Password Combination" | ||
end | ||
end | ||
end | ||
end | ||
@current_user | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Ui | ||
class ApplicationController < ActionController::Base | ||
layout "application" | ||
include SharedControllerMethods | ||
end | ||
end |
Oops, something went wrong.