Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
c7c1a97c
Commit
c7c1a97c
authored
Jan 18, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2050 from dosire/allow_self_signup
Add optional signup
parents
b07e1b3a
296cdd59
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
125 additions
and
25 deletions
+125
-25
app/assets/stylesheets/sections/login.scss
app/assets/stylesheets/sections/login.scss
+5
-0
app/controllers/registrations_controller.rb
app/controllers/registrations_controller.rb
+9
-0
app/models/user.rb
app/models/user.rb
+1
-1
app/views/devise/passwords/new.html.erb
app/views/devise/passwords/new.html.erb
+1
-1
app/views/devise/registrations/new.html.erb
app/views/devise/registrations/new.html.erb
+0
-18
app/views/devise/registrations/new.html.haml
app/views/devise/registrations/new.html.haml
+19
-0
app/views/devise/sessions/new.html.haml
app/views/devise/sessions/new.html.haml
+7
-1
app/views/notify/new_user_email.html.haml
app/views/notify/new_user_email.html.haml
+7
-3
config/gitlab.yml.example
config/gitlab.yml.example
+1
-0
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+1
-0
config/routes.rb
config/routes.rb
+1
-1
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+30
-0
spec/requests/admin/admin_users_spec.rb
spec/requests/admin/admin_users_spec.rb
+13
-0
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+30
-0
No files found.
app/assets/stylesheets/sections/login.scss
View file @
c7c1a97c
...
@@ -31,4 +31,9 @@ body.login-page{
...
@@ -31,4 +31,9 @@ body.login-page{
margin-bottom
:
20px
;
margin-bottom
:
20px
;
}
}
.login-box
input
.text.middle
{
border-top
:
0
;
margin-bottom
:
0px
;
}
.login-box
a
.forgot
{
float
:
right
;
padding-top
:
6px
}
.login-box
a
.forgot
{
float
:
right
;
padding-top
:
6px
}
app/controllers/registrations_controller.rb
0 → 100644
View file @
c7c1a97c
class
RegistrationsController
<
Devise
::
RegistrationsController
before_filter
:signup_enabled?
private
def
signup_enabled?
redirect_to
new_user_session_path
unless
Gitlab
.
config
.
gitlab
.
signup_enabled
end
end
\ No newline at end of file
app/models/user.rb
View file @
c7c1a97c
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
class
User
<
ActiveRecord
::
Base
class
User
<
ActiveRecord
::
Base
devise
:database_authenticatable
,
:token_authenticatable
,
:lockable
,
devise
:database_authenticatable
,
:token_authenticatable
,
:lockable
,
:recoverable
,
:rememberable
,
:trackable
,
:validatable
,
:omniauthable
:recoverable
,
:rememberable
,
:trackable
,
:validatable
,
:omniauthable
,
:registerable
attr_accessible
:email
,
:password
,
:password_confirmation
,
:remember_me
,
:bio
,
:name
,
:username
,
attr_accessible
:email
,
:password
,
:password_confirmation
,
:remember_me
,
:bio
,
:name
,
:username
,
:skype
,
:linkedin
,
:twitter
,
:dark_scheme
,
:theme_id
,
:force_random_password
,
:skype
,
:linkedin
,
:twitter
,
:dark_scheme
,
:theme_id
,
:force_random_password
,
...
...
app/views/devise/passwords/new.html.erb
View file @
c7c1a97c
...
@@ -5,5 +5,5 @@
...
@@ -5,5 +5,5 @@
<br/>
<br/>
<br/>
<br/>
<%=
f
.
submit
"Reset password"
,
:class
=>
"primary btn"
%>
<%=
f
.
submit
"Reset password"
,
:class
=>
"primary btn"
%>
<div
class=
"right"
>
<%=
render
:partial
=>
"devise/shared/links"
%
>
</div>
<div
class=
"right"
>
<%=
link_to
"Sign in"
,
new_session_path
(
resource_name
),
:class
=>
"btn"
%>
<br
/
></div>
<%
end
%>
<%
end
%>
app/views/devise/registrations/new.html.erb
deleted
100644 → 0
View file @
b07e1b3a
<h2>
Sign up
</h2>
<%=
form_for
(
resource
,
:as
=>
resource_name
,
:url
=>
registration_path
(
resource_name
))
do
|
f
|
%>
<%=
devise_error_messages!
%>
<div>
<%=
f
.
label
:email
%>
<br
/>
<%=
f
.
email_field
:email
%>
</div>
<div>
<%=
f
.
label
:password
%>
<br
/>
<%=
f
.
password_field
:password
%>
</div>
<div>
<%=
f
.
label
:password_confirmation
%>
<br
/>
<%=
f
.
password_field
:password_confirmation
%>
</div>
<div>
<%=
f
.
submit
"Sign up"
,
:class
=>
"input_button"
%>
</div>
<%
end
%>
<%=
render
:partial
=>
"devise/shared/links"
%>
app/views/devise/registrations/new.html.haml
0 → 100644
View file @
c7c1a97c
=
form_for
(
resource
,
:as
=>
resource_name
,
:url
=>
registration_path
(
resource_name
),
:html
=>
{
:class
=>
"login-box"
})
do
|
f
|
=
image_tag
"login-logo.png"
,
:width
=>
"304"
,
:height
=>
"66"
,
:class
=>
"login-logo"
,
:alt
=>
"Login Logo"
=
devise_error_messages!
%div
=
f
.
text_field
:name
,
:class
=>
"text top"
,
:placeholder
=>
"Name"
,
:required
=>
true
%div
=
f
.
text_field
:username
,
:class
=>
"text middle"
,
:placeholder
=>
"Username"
,
:required
=>
true
%div
=
f
.
email_field
:email
,
:class
=>
"text middle"
,
:placeholder
=>
"Email"
,
:required
=>
true
%div
=
f
.
password_field
:password
,
:class
=>
"text middle"
,
:placeholder
=>
"Password"
,
:required
=>
true
%div
=
f
.
password_field
:password_confirmation
,
:class
=>
"text bottom"
,
:placeholder
=>
"Confirm password"
,
:required
=>
true
%div
=
f
.
submit
"Sign up"
,
:class
=>
"primary btn wide"
%br
%hr
=
link_to
"Sign in"
,
new_session_path
(
resource_name
)
=
link_to
"Forgot your password?"
,
new_password_path
(
resource_name
),
:class
=>
"right"
app/views/devise/sessions/new.html.haml
View file @
c7c1a97c
...
@@ -13,7 +13,13 @@
...
@@ -13,7 +13,13 @@
%br
/
%br
/
=
f
.
submit
"Sign in"
,
:class
=>
"primary btn wide"
=
f
.
submit
"Sign in"
,
:class
=>
"primary btn wide"
.right
.right
=
render
:partial
=>
"devise/shared/links"
=
link_to
"Forgot your password?"
,
new_password_path
(
resource_name
),
:class
=>
"btn"
%br
/
%br
/
-
if
Gitlab
.
config
.
gitlab
.
signup_enabled
%hr
/
Don't have an account?
=
link_to
"Sign up"
,
new_registration_path
(
resource_name
)
.clearfix
.clearfix
-
if
devise_mapping
.
omniauthable?
&&
resource_class
.
omniauth_providers
.
present?
-
if
devise_mapping
.
omniauthable?
&&
resource_class
.
omniauth_providers
.
present?
%div
%div
...
...
app/views/notify/new_user_email.html.haml
View file @
c7c1a97c
...
@@ -6,7 +6,10 @@
...
@@ -6,7 +6,10 @@
%h2
{
style:
"color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "
}
%h2
{
style:
"color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "
}
Hi
#{
@user
[
'name'
]
}
!
Hi
#{
@user
[
'name'
]
}
!
%p
{
style:
"color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "
}
%p
{
style:
"color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "
}
Administrator created account for you. Now you are a member of company GitLab application.
-
if
Gitlab
.
config
.
gitlab
.
signup_enabled
Account has been created successfully.
-
else
Administrator created account for you. Now you are a member of company GitLab application.
%td
{
style:
"font-size: 1px; line-height: 1px;"
,
width:
"21"
}
%td
{
style:
"font-size: 1px; line-height: 1px;"
,
width:
"21"
}
%tr
%tr
%td
{
style:
"font-size: 1px; line-height: 1px;"
,
width:
"21"
}
%td
{
style:
"font-size: 1px; line-height: 1px;"
,
width:
"21"
}
...
@@ -15,8 +18,9 @@
...
@@ -15,8 +18,9 @@
login..........................................
login..........................................
%code
=
@user
[
'email'
]
%code
=
@user
[
'email'
]
%p
{
style:
"color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 28px; font-size: 16px;font-family: Helvetica, Arial, sans-serif; "
}
%p
{
style:
"color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 28px; font-size: 16px;font-family: Helvetica, Arial, sans-serif; "
}
password..................................
-
unless
Gitlab
.
config
.
gitlab
.
signup_enabled
%code
=
@password
password..................................
%code
=
@password
%p
{
style:
"color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 28px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "
}
%p
{
style:
"color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 28px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "
}
=
link_to
"Click here to login"
,
root_url
=
link_to
"Click here to login"
,
root_url
%td
{
style:
"font-size: 1px; line-height: 1px;"
,
width:
"21"
}
%td
{
style:
"font-size: 1px; line-height: 1px;"
,
width:
"21"
}
...
...
config/gitlab.yml.example
View file @
c7c1a97c
...
@@ -31,6 +31,7 @@ gitlab:
...
@@ -31,6 +31,7 @@ gitlab:
## Project settings
## Project settings
default_projects_limit: 10
default_projects_limit: 10
# signup_enabled: true # default: false - Account passwords are not sent via the email if signup is enabled.
## Gravatar
## Gravatar
gravatar:
gravatar:
...
...
config/initializers/1_settings.rb
View file @
c7c1a97c
...
@@ -51,6 +51,7 @@ Settings.gitlab['protocol'] ||= Settings.gitlab.https ? "https" : "http"
...
@@ -51,6 +51,7 @@ Settings.gitlab['protocol'] ||= Settings.gitlab.https ? "https" : "http"
Settings
.
gitlab
[
'email_from'
]
||=
"gitlab@
#{
Settings
.
gitlab
.
host
}
"
Settings
.
gitlab
[
'email_from'
]
||=
"gitlab@
#{
Settings
.
gitlab
.
host
}
"
Settings
.
gitlab
[
'url'
]
||=
Settings
.
send
(
:build_gitlab_url
)
Settings
.
gitlab
[
'url'
]
||=
Settings
.
send
(
:build_gitlab_url
)
Settings
.
gitlab
[
'user'
]
||=
'gitlab'
Settings
.
gitlab
[
'user'
]
||=
'gitlab'
Settings
.
gitlab
[
'signup_enabled'
]
||=
false
Settings
[
'gravatar'
]
||=
Settingslogic
.
new
({})
Settings
[
'gravatar'
]
||=
Settingslogic
.
new
({})
Settings
.
gravatar
[
'enabled'
]
=
true
if
Settings
.
gravatar
[
'enabled'
].
nil?
Settings
.
gravatar
[
'enabled'
]
=
true
if
Settings
.
gravatar
[
'enabled'
].
nil?
...
...
config/routes.rb
View file @
c7c1a97c
...
@@ -121,7 +121,7 @@ Gitlab::Application.routes.draw do
...
@@ -121,7 +121,7 @@ Gitlab::Application.routes.draw do
resources
:projects
,
constraints:
{
id:
/[^\/]+/
},
only:
[
:new
,
:create
]
resources
:projects
,
constraints:
{
id:
/[^\/]+/
},
only:
[
:new
,
:create
]
devise_for
:users
,
controllers:
{
omniauth_callbacks: :omniauth_callbacks
}
devise_for
:users
,
controllers:
{
omniauth_callbacks: :omniauth_callbacks
,
registrations: :registrations
}
#
#
# Project Area
# Project Area
...
...
spec/mailers/notify_spec.rb
View file @
c7c1a97c
...
@@ -32,6 +32,7 @@ describe Notify do
...
@@ -32,6 +32,7 @@ describe Notify do
end
end
it
'contains the new user\'s password'
do
it
'contains the new user\'s password'
do
Gitlab
.
config
.
gitlab
.
stub
(
:signup_enabled
).
and_return
(
false
)
should
have_body_text
/
#{
new_user
.
password
}
/
should
have_body_text
/
#{
new_user
.
password
}
/
end
end
...
@@ -40,6 +41,35 @@ describe Notify do
...
@@ -40,6 +41,35 @@ describe Notify do
end
end
end
end
describe
'for users that signed up, the email'
do
let
(
:example_site_path
)
{
root_path
}
let
(
:new_user
)
{
create
(
:user
,
email:
'newguy@example.com'
,
password:
"securePassword"
)
}
subject
{
Notify
.
new_user_email
(
new_user
.
id
,
new_user
.
password
)
}
it
'is sent to the new user'
do
should
deliver_to
new_user
.
email
end
it
'has the correct subject'
do
should
have_subject
/^gitlab \| Account was created for you$/i
end
it
'contains the new user\'s login name'
do
should
have_body_text
/
#{
new_user
.
email
}
/
end
it
'should not contain the new user\'s password'
do
Gitlab
.
config
.
gitlab
.
stub
(
:signup_enabled
).
and_return
(
true
)
should_not
have_body_text
/
#{
new_user
.
password
}
/
end
it
'includes a link to the site'
do
should
have_body_text
/
#{
example_site_path
}
/
end
end
context
'for a project'
do
context
'for a project'
do
describe
'items that are assignable, the email'
do
describe
'items that are assignable, the email'
do
let
(
:assignee
)
{
create
(
:user
,
email:
'assignee@example.com'
)
}
let
(
:assignee
)
{
create
(
:user
,
email:
'assignee@example.com'
)
}
...
...
spec/requests/admin/admin_users_spec.rb
View file @
c7c1a97c
...
@@ -49,6 +49,7 @@ describe "Admin::Users" do
...
@@ -49,6 +49,7 @@ describe "Admin::Users" do
end
end
it
"should send valid email to user with email & password"
do
it
"should send valid email to user with email & password"
do
Gitlab
.
config
.
gitlab
.
stub
(
:signup_enabled
).
and_return
(
false
)
User
.
observers
.
enable
:user_observer
do
User
.
observers
.
enable
:user_observer
do
click_button
"Save"
click_button
"Save"
user
=
User
.
last
user
=
User
.
last
...
@@ -58,6 +59,18 @@ describe "Admin::Users" do
...
@@ -58,6 +59,18 @@ describe "Admin::Users" do
email
.
body
.
should
have_content
(
@password
)
email
.
body
.
should
have_content
(
@password
)
end
end
end
end
it
"should send valid email to user with email without password when signup is enabled"
do
Gitlab
.
config
.
gitlab
.
stub
(
:signup_enabled
).
and_return
(
true
)
User
.
observers
.
enable
:user_observer
do
click_button
"Save"
user
=
User
.
last
email
=
ActionMailer
::
Base
.
deliveries
.
last
email
.
subject
.
should
have_content
(
"Account was created"
)
email
.
body
.
should
have_content
(
user
.
email
)
email
.
body
.
should_not
have_content
(
@password
)
end
end
end
end
describe
"GET /admin/users/:id"
do
describe
"GET /admin/users/:id"
do
...
...
spec/requests/api/users_spec.rb
View file @
c7c1a97c
...
@@ -53,6 +53,36 @@ describe Gitlab::API do
...
@@ -53,6 +53,36 @@ describe Gitlab::API do
end
end
end
end
describe
"GET /users/sign_up"
do
before
do
Gitlab
.
config
.
gitlab
.
stub
(
:signup_enabled
).
and_return
(
false
)
end
it
"should redirect to sign in page if signup is disabled"
do
get
"/users/sign_up"
response
.
status
.
should
==
302
response
.
should
redirect_to
(
new_user_session_path
)
end
end
describe
"GET /users/sign_up"
do
before
do
Gitlab
.
config
.
gitlab
.
stub
(
:signup_enabled
).
and_return
(
true
)
end
it
"should return sign up page if signup is enabled"
do
get
"/users/sign_up"
response
.
status
.
should
==
200
end
it
"should create a new user account"
do
visit
new_user_registration_path
fill_in
"user_name"
,
with:
"Name Surname"
fill_in
"user_username"
,
with:
"Great"
fill_in
"user_email"
,
with:
"name@mail.com"
fill_in
"user_password"
,
with:
"password1234"
fill_in
"user_password_confirmation"
,
with:
"password1234"
expect
{
click_button
"Sign up"
}.
to
change
{
User
.
count
}.
by
(
1
)
end
end
describe
"GET /user"
do
describe
"GET /user"
do
it
"should return current user"
do
it
"should return current user"
do
get
api
(
"/user"
,
user
)
get
api
(
"/user"
,
user
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment