-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e1f4ed
commit 49f12b3
Showing
35 changed files
with
1,104 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
-----BEGIN PUBLIC KEY----- | ||
MIIEFjANBgkqhkiG9w0BAQEFAAOCBAMAMIID/gKCA/UAquIZchoog2ffcr9J2KSl | ||
mlum6sN3smTVNsp9JGd1q4fr/kUFGch6q1cFEX3x5BGDXx7wPPI4ppKzeQHaxWmx | ||
wxqs3eevcTFUEF9A2MPX7p5Ia0TbH4d7e7D9YMWvDXoQLggrxMFdUHY3ppUnBPgB | ||
+EJG1Pv0FlBAdxYX0em7kLwhcp9PBP/zXso/qkkKK/pncyKizOLC3zv3E0ixcQ7o | ||
Nq0aolTJFMHcqEquKaQN1jicDdzU6ks+YKh7kByZvVChe/InlroVXKrUa34hAZDM | ||
acEkURJma3meN0IyPFA7fHRe1AhiNYF2MatNKysPrbOffYLOjamlaqmHTeJAec6e | ||
vMHd+LlIz4xXivR0lY2wDawqp0waSLJaW8lZetOf0iwbqQkzZhz4sWDZopyGiqAU | ||
v9/zS4OjUBr7JQbVcV3LIkzGWwNysSvTMrlvzCesYVsCwpLjP6gFxdclYJuTwEeL | ||
o+T+AgoNyuj6ixhwHTJxIVhuBpebX44/YTYyUGMgItekDCH2Dxvtv2DaCL7YIqNG | ||
ibvCyzCyLak7Tz97CMvCUf1EIRVfolbGpphi2Zzpoeqhfheh+0LQ3gmMBJpuLnJU | ||
VXEtrOPunTkOrdUqL5rD/+mfd8yufsJ16Uk5j7gNUcIJsCcGWZ3Nhfidi3tvmJPF | ||
H8HgNZ6W6smj9k7+TdZbRsH1LZp1LL/stLch3ffFHHcJye7d2t75uKiOoz1/1JMY | ||
fl/wfaEaKvTGBKr/NFKcVDSBXHgx6VMA3oWV2AyLnTaY98XVPY1zzbyNKlNQkSaD | ||
p/VCl334+YMwR9/5aJYJg58lljw6aBu+cozNkydKjCmqEpZNdR1tFusAY7jd/M2G | ||
yXPBTdUJD6GrLx0Hot/wImJ30gOMgpeoetNUfM9/FimySLy65DRzCtLm1hthAlWM | ||
Is5vFwMmFFSb3ozTsnkj9W16jHk9HdodKJfezzcPqu3TW2EMMNbbtXa3OPaHkht2 | ||
huYJGnGu0hNhAj+x+KCxkpLveS0Ajw322qmtAqnwJLvfwShnz//cptNX5kXtrNGy | ||
+o6I4jHibIATfaMKMt8gHmCZ381zAwrAOU7c0FQna+IkU8dgZDx7T+Xo1Q/GXuaO | ||
1b2aT6geT60A3VgF+OBnoHe5Ext7vfNL9v0wcN5NLR5KgjexwEhcBcA2FauCTrVt | ||
FUNgir+5XALd/wBlvxkvPKTJnQld/aK7xF0ui3c3/ryPX5cKzpfm9APK/hOFzkJ7 | ||
ieARHqrQGqOYdClIUJIH0b/92dFq49Eqn1cKpztVzsU9xzdI/4w5JUSw/kbguVf7 | ||
Yd0Rdc9KF/9WMwjzrWSti4meNBUO6/18cAognx0Pf5qsrSzOewIDAQAB | ||
-----END PUBLIC KEY----- |
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
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,13 @@ | ||
.upsale-notification | ||
max-width: 560px | ||
margin-bottom: 20px | ||
padding-bottom: 20px | ||
|
||
.widget-box--teaser-image | ||
width: 30% | ||
float: right | ||
margin-top: -20px | ||
|
||
.token-form textarea | ||
font-family: "Lucida Console", Monaco, monospace | ||
max-width: 560px |
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
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,67 @@ | ||
#-- copyright | ||
# OpenProject is a project management system. | ||
# Copyright (C) 2012-2017 the OpenProject Foundation (OPF) | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public token version 3. | ||
# | ||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: | ||
# Copyright (C) 2006-2017 Jean-Philippe Lang | ||
# Copyright (C) 2010-2013 the ChiliProject Team | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public token | ||
# as published by the Free Software Foundation; either version 2 | ||
# of the token, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public token for more details. | ||
# | ||
# You should have received a copy of the GNU General Public token | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
# | ||
# See doc/COPYRIGHT.rdoc for more details. | ||
#++ | ||
class EnterprisesController < ApplicationController | ||
layout 'admin' | ||
menu_item :enterprise | ||
|
||
before_action :require_admin | ||
|
||
def show | ||
@current_token = EnterpriseToken.current | ||
@token = @current_token || EnterpriseToken.new | ||
end | ||
|
||
def create | ||
@token = EnterpriseToken.current || EnterpriseToken.new | ||
@token.encoded_token = params[:enterprise_token][:encoded_token] | ||
|
||
if @token.save | ||
flash[:notice] = t(:notice_successful_update) | ||
redirect_to action: :show | ||
else | ||
render action: :show | ||
end | ||
end | ||
|
||
def destroy | ||
token = EnterpriseToken.current | ||
if token | ||
token.destroy | ||
flash[:notice] = t(:notice_successful_delete) | ||
redirect_to action: :show | ||
else | ||
render_404 | ||
end | ||
end | ||
|
||
private | ||
|
||
def default_breadcrumb | ||
t(:label_enterprise) | ||
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,107 @@ | ||
#-- copyright | ||
# OpenProject is a project management system. | ||
# Copyright (C) 2012-2017 the OpenProject Foundation (OPF) | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License version 3. | ||
# | ||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: | ||
# Copyright (C) 2006-2017 Jean-Philippe Lang | ||
# Copyright (C) 2010-2013 the ChiliProject Team | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation; either version 2 | ||
# of the License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
# | ||
# See doc/COPYRIGHT.rdoc for more details. | ||
#++ | ||
class EnterpriseToken < ActiveRecord::Base | ||
class << self | ||
def current | ||
RequestStore.fetch(cache_key) do | ||
set_current_token | ||
end | ||
end | ||
|
||
def cache_key | ||
RequestStore.fetch(:current_ee_token_updated_at) { EnterpriseToken.maximum(:updated_at) } | ||
most_recent_update = (RequestStore[:current_ee_token_updated_at] || Time.now.utc).to_i | ||
"/openproject/ee/#{most_recent_update}" | ||
end | ||
|
||
def clear_cache(key = cache_key) | ||
Rails.cache.delete(key) | ||
RequestStore.delete key | ||
RequestStore.delete :current_ee_token_updated_at | ||
end | ||
|
||
def allows_to?(action) | ||
Authorization::EnterpriseService.new(current).call(action).result | ||
end | ||
|
||
def show_banners | ||
!current || current.expired? | ||
end | ||
|
||
def set_current_token | ||
token = EnterpriseToken.order('created_at DESC').first | ||
|
||
if token && token.token_object | ||
token | ||
end | ||
end | ||
end | ||
|
||
validates_presence_of :encoded_token | ||
validate :valid_token_object | ||
|
||
before_save :unset_current_token | ||
before_destroy :unset_current_token | ||
|
||
delegate :will_expire?, | ||
:expired?, | ||
:subscriber, | ||
:mail, | ||
:issued_at, | ||
:starts_at, | ||
:expires_at, | ||
:restrictions, | ||
to: :token_object | ||
|
||
def token_object | ||
@token_object = load_token unless defined?(@token_object) | ||
@token_object | ||
end | ||
|
||
def allows_to?(action) | ||
Authorization::EnterpriseService.new(self).call(action).result | ||
end | ||
|
||
def unset_current_token | ||
# Clear current cache | ||
self.class.clear_cache | ||
end | ||
|
||
private | ||
|
||
def load_token | ||
OpenProject::Token.import(encoded_token) | ||
rescue OpenProject::Token::ImportError => error | ||
Rails.logger.error "Failed to load EE token: #{error}" | ||
nil | ||
end | ||
|
||
def valid_token_object | ||
errors.add(:encoded_token, :unreadable) unless token_object | ||
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 |
---|---|---|
|
@@ -33,7 +33,7 @@ def self.model | |
Relation | ||
end | ||
|
||
def self.default_scope | ||
def default_scope | ||
Relation.all | ||
end | ||
end | ||
|
Oops, something went wrong.