-
Notifications
You must be signed in to change notification settings - Fork 438
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
Showing
3 changed files
with
68 additions
and
0 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,29 @@ | ||
- if proxy_auth_enabled? | ||
- if proxy_auth_register_page.blank? | ||
%p Sorry, signing up is currently disabled | ||
- else | ||
%p= link_to 'Use this link to Sign Up', proxy_auth_register_page | ||
- else | ||
= form_tag(users_path, method: :post, class: 'sign-up', autocomplete: 'off') do | ||
.form-group | ||
= label_tag 'login', 'Username:' | ||
%abbr.text-danger{ title: 'required' } * | ||
= text_field_tag 'login', nil, placeholder: 'Username', autocomplete: 'off', class: 'form-control', required: true | ||
.form-group | ||
= label_tag 'email', 'Email:' | ||
%abbr.text-danger{ title: 'required' } * | ||
= text_field_tag 'email', nil, placeholder: 'Email address', autocomplete: 'off', class: 'form-control', type: 'email', required: true | ||
.form-group | ||
= label_tag 'password', 'Password:' | ||
%abbr.text-danger{ title: 'required' } * | ||
= password_field_tag :password, nil, id: 'pwd', placeholder: 'Enter a password', autocomplete: 'off', class: 'form-control', required: true | ||
.form-group | ||
= label_tag 'password_confirmation', 'Password confirmation:' | ||
%abbr.text-danger{ title: 'required' } * | ||
= password_field_tag(:password_confirmation, nil, id: 'pwd_confirmation', placeholder: 'Password confirmation', autocomplete: 'off', | ||
class: 'form-control', required: true) | ||
= hidden_field_tag 'register', 'true' | ||
= submit_tag submit_btn_text, class: 'btn btn-primary' | ||
- unless User.session | ||
or | ||
= link_to('Log In', new_session_path) |
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,20 @@ | ||
# frozen_string_literal: true | ||
|
||
class SignUpComponent < ApplicationComponent | ||
attr_accessor :submit_btn_text | ||
|
||
def initialize(submit_btn_text: 'Sign Up', create_page: false, config: CONFIG) | ||
super | ||
|
||
@config = config | ||
@submit_btn_text = sanitize(create_page ? 'Create' : submit_btn_text) | ||
end | ||
|
||
def proxy_auth_enabled? | ||
@config['proxy_auth_mode'] == :on | ||
end | ||
|
||
def proxy_auth_register_page | ||
@config['proxy_auth_register_page'] | ||
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,19 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe SignUpComponent, type: :component do | ||
context 'signing up disabled' do | ||
let(:config) { { 'proxy_auth_mode' => :on } } | ||
|
||
it do | ||
expect(render_inline(described_class.new(config: config)).to_html).to have_text('signing up is currently disabled') | ||
end | ||
|
||
context 'there is a proxy auth register page' do | ||
let(:config) { { 'proxy_auth_mode' => :on, 'proxy_auth_register_page' => 'http://foo.org' } } | ||
|
||
it do | ||
expect(render_inline(described_class.new(config: config)).to_html).to have_text('Use this link to Sign Up') | ||
end | ||
end | ||
end | ||
end |