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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
5eb73490
Commit
5eb73490
authored
Jun 24, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'oauth_errors' into 'master'
Oauth errors page
parents
5c5a02da
8307704c
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
62 additions
and
24 deletions
+62
-24
app/assets/stylesheets/generic/common.scss
app/assets/stylesheets/generic/common.scss
+0
-7
app/assets/stylesheets/sections/errors.scss
app/assets/stylesheets/sections/errors.scss
+14
-0
app/controllers/omniauth_callbacks_controller.rb
app/controllers/omniauth_callbacks_controller.rb
+15
-4
app/views/errors/access_denied.html.haml
app/views/errors/access_denied.html.haml
+2
-2
app/views/errors/encoding.html.haml
app/views/errors/encoding.html.haml
+2
-2
app/views/errors/git_not_found.html.haml
app/views/errors/git_not_found.html.haml
+2
-2
app/views/errors/not_found.html.haml
app/views/errors/not_found.html.haml
+2
-2
app/views/errors/omniauth_error.html.haml
app/views/errors/omniauth_error.html.haml
+12
-0
app/views/layouts/errors.html.haml
app/views/layouts/errors.html.haml
+3
-4
config/routes.rb
config/routes.rb
+3
-0
lib/gitlab/oauth/user.rb
lib/gitlab/oauth/user.rb
+7
-1
No files found.
app/assets/stylesheets/generic/common.scss
View file @
5eb73490
...
@@ -257,13 +257,6 @@ li.note {
...
@@ -257,13 +257,6 @@ li.note {
}
}
}
}
h1
.http_status_code
{
font-size
:
56px
;
line-height
:
100px
;
font-weight
:
normal
;
color
:
#456
;
}
.control-group
{
.control-group
{
.controls
{
.controls
{
span
{
span
{
...
...
app/assets/stylesheets/sections/errors.scss
0 → 100644
View file @
5eb73490
.error-page
{
max-width
:
400px
;
margin
:
0
auto
;
h1
,
h2
,
h3
{
text-align
:
center
;
}
h1
{
font-size
:
56px
;
line-height
:
100px
;
font-weight
:
300
;
}
}
app/controllers/omniauth_callbacks_controller.rb
View file @
5eb73490
...
@@ -31,6 +31,12 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
...
@@ -31,6 +31,12 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
end
end
end
end
def
omniauth_error
@provider
=
params
[
:provider
]
@error
=
params
[
:error
]
render
'errors/omniauth_error'
,
layout:
"errors"
,
status:
422
end
private
private
def
handle_omniauth
def
handle_omniauth
...
@@ -45,14 +51,19 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
...
@@ -45,14 +51,19 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
# Create user if does not exist
# Create user if does not exist
# and allow_single_sign_on is true
# and allow_single_sign_on is true
if
Gitlab
.
config
.
omniauth
[
'allow_single_sign_on'
]
if
Gitlab
.
config
.
omniauth
[
'allow_single_sign_on'
]
&&
!
@user
@user
||
=
Gitlab
::
OAuth
::
User
.
create
(
oauth
)
@user
,
errors
=
Gitlab
::
OAuth
::
User
.
create
(
oauth
)
end
end
if
@user
if
@user
&&
!
errors
sign_in_and_redirect
(
@user
)
sign_in_and_redirect
(
@user
)
else
else
flash
[
:notice
]
=
"There's no such user!"
if
errors
error_message
=
errors
.
map
{
|
attribute
,
message
|
"
#{
attribute
}
#{
message
}
"
}.
join
(
", "
)
redirect_to
omniauth_error_path
(
oauth
[
'provider'
],
error:
error_message
)
and
return
else
flash
[
:notice
]
=
"There's no such user!"
end
redirect_to
new_user_session_path
redirect_to
new_user_session_path
end
end
end
end
...
...
app/views/errors/access_denied.html.haml
View file @
5eb73490
%h1
.http_status_code
403
%h1
403
%h3
.page-title
Access Denied
%h3
Access Denied
%hr
%hr
%p
You are not allowed to access this page.
%p
You are not allowed to access this page.
%p
Read more about project permissions
#{
link_to
"here"
,
help_page_path
(
"permissions"
,
"permissions"
),
class:
"vlink"
}
%p
Read more about project permissions
#{
link_to
"here"
,
help_page_path
(
"permissions"
,
"permissions"
),
class:
"vlink"
}
app/views/errors/encoding.html.haml
View file @
5eb73490
%h1
.http_status_code
500
%h1
500
%h3
.page-title
Encoding Error
%h3
Encoding Error
%hr
%hr
%p
Page can't be loaded because of an encoding error.
%p
Page can't be loaded because of an encoding error.
app/views/errors/git_not_found.html.haml
View file @
5eb73490
%h1
.http_status_code
404
%h1
404
%h3
.page-title
Git Resource Not found
%h3
Git Resource Not found
%hr
%hr
%p
%p
Application can't get access to some branch or commit in your repository. It
Application can't get access to some branch or commit in your repository. It
...
...
app/views/errors/not_found.html.haml
View file @
5eb73490
%h1
.http_status_code
404
%h1
404
%h3
.page-title
The resource you were looking for doesn't exist.
%h3
The resource you were looking for doesn't exist.
%hr
%hr
%p
You may have mistyped the address or the page may have moved.
%p
You may have mistyped the address or the page may have moved.
app/views/errors/omniauth_error.html.haml
0 → 100644
View file @
5eb73490
%h1
422
%h3
Sign-in using
#{
@provider
}
auth failed
%hr
%p
Sign-in failed because
#{
@error
}
.
%p
There are couple of steps you can take:
%ul
%li
Try logging in using your email
%li
Try logging in using your username
%li
If you have forgotten your password, try recovering it using
#{
link_to
"Password recovery"
,
new_password_path
(
resource_name
)
}
%p
If none of the options work, try contacting the GitLab administrator.
app/views/layouts/errors.html.haml
View file @
5eb73490
...
@@ -4,7 +4,6 @@
...
@@ -4,7 +4,6 @@
%body
{
class:
"#{app_theme} application"
}
%body
{
class:
"#{app_theme} application"
}
=
render
"layouts/head_panel"
,
title:
""
if
current_user
=
render
"layouts/head_panel"
,
title:
""
if
current_user
=
render
"layouts/flash"
=
render
"layouts/flash"
.container
.container.navless-container
.content
.error-page
.center.padded.prepend-top-20
=
yield
=
yield
config/routes.rb
View file @
5eb73490
...
@@ -160,6 +160,9 @@ Gitlab::Application.routes.draw do
...
@@ -160,6 +160,9 @@ Gitlab::Application.routes.draw do
devise_for
:users
,
controllers:
{
omniauth_callbacks: :omniauth_callbacks
,
registrations: :registrations
,
passwords: :passwords
,
sessions: :users_sessions
}
devise_for
:users
,
controllers:
{
omniauth_callbacks: :omniauth_callbacks
,
registrations: :registrations
,
passwords: :passwords
,
sessions: :users_sessions
}
devise_scope
:user
do
get
"/users/auth/:provider/omniauth_error"
=>
"omniauth_callbacks#omniauth_error"
,
as: :omniauth_error
end
#
#
# Project Area
# Project Area
#
#
...
...
lib/gitlab/oauth/user.rb
View file @
5eb73490
...
@@ -44,7 +44,13 @@ module Gitlab
...
@@ -44,7 +44,13 @@ module Gitlab
user
.
username
=
email_username
.
gsub
(
"'"
,
""
)
user
.
username
=
email_username
.
gsub
(
"'"
,
""
)
end
end
user
.
save!
begin
user
.
save!
rescue
ActiveRecord
::
RecordInvalid
=>
e
log
.
info
"(OAuth) Email
#{
e
.
record
.
errors
[
:email
]
}
. Username
#{
e
.
record
.
errors
[
:username
]
}
"
return
nil
,
e
.
record
.
errors
end
log
.
info
"(OAuth) Creating user
#{
email
}
from login with extern_uid =>
#{
uid
}
"
log
.
info
"(OAuth) Creating user
#{
email
}
from login with extern_uid =>
#{
uid
}
"
if
Gitlab
.
config
.
omniauth
[
'block_auto_created_users'
]
&&
!
ldap?
if
Gitlab
.
config
.
omniauth
[
'block_auto_created_users'
]
&&
!
ldap?
...
...
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