Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
04d03f73
Commit
04d03f73
authored
Jan 29, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added disable user sign up feature
parent
d95c5e66
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
21 additions
and
6 deletions
+21
-6
conf/grafana.ini
+1
-1
grafana
+1
-1
pkg/api/api.go
+1
-1
pkg/api/login.go
+3
-2
pkg/api/login_oauth.go
+5
-0
pkg/api/signup.go
+5
-0
pkg/cmd/web.go
+2
-0
pkg/middleware/middleware.go
+1
-1
pkg/setting/setting.go
+2
-0
No files found.
conf/grafana.ini
View file @
04d03f73
...
...
@@ -59,7 +59,7 @@ login_remember_days = 7
cookie_username
=
grafana_user
cookie_remember_name
=
grafana_remember
; disable user signup / registration
; disable_user_signup = false, not implemented yet
disable_user_signup
=
false
[account.single]
; Enable this feature to auto assign new users to a single account, suitable for NON multi tenant setups
...
...
grafana
@
740709da
Subproject commit
3b5c813be71c4816f3c2ef40e4c1439a8026236f
Subproject commit
740709da0493536269adfe1cafd0b93d975b02a2
pkg/api/api.go
View file @
04d03f73
...
...
@@ -18,7 +18,7 @@ func Register(r *macaron.Macaron) {
// not logged in views
r
.
Get
(
"/"
,
reqSignedIn
,
Index
)
r
.
Post
(
"/logout"
,
LogoutPos
t
)
r
.
Get
(
"/logout"
,
Logou
t
)
r
.
Post
(
"/login"
,
bind
(
dtos
.
LoginCommand
{}),
LoginPost
)
r
.
Get
(
"/login/:name"
,
OAuthLogin
)
r
.
Get
(
"/login"
,
LoginView
)
...
...
pkg/api/login.go
View file @
04d03f73
...
...
@@ -25,6 +25,7 @@ func LoginView(c *middleware.Context) {
settings
:=
c
.
Data
[
"Settings"
]
.
(
map
[
string
]
interface
{})
settings
[
"googleAuthEnabled"
]
=
setting
.
OAuthService
.
Google
settings
[
"githubAuthEnabled"
]
=
setting
.
OAuthService
.
GitHub
settings
[
"disableUserSignUp"
]
=
setting
.
DisableUserSignUp
// Check auto-login.
uname
:=
c
.
GetCookie
(
setting
.
CookieUserName
)
...
...
@@ -122,9 +123,9 @@ func loginUserWithUser(user *m.User, c *middleware.Context) {
c
.
Session
.
Set
(
middleware
.
SESS_KEY_USERID
,
user
.
Id
)
}
func
Logout
Post
(
c
*
middleware
.
Context
)
{
func
Logout
(
c
*
middleware
.
Context
)
{
c
.
SetCookie
(
setting
.
CookieUserName
,
""
,
-
1
,
setting
.
AppSubUrl
+
"/"
)
c
.
SetCookie
(
setting
.
CookieRememberName
,
""
,
-
1
,
setting
.
AppSubUrl
+
"/"
)
c
.
Session
.
Destory
(
c
.
Context
)
c
.
JsonOK
(
"logged out
"
)
c
.
Redirect
(
setting
.
AppSubUrl
+
"/login
"
)
}
pkg/api/login_oauth.go
View file @
04d03f73
...
...
@@ -56,6 +56,11 @@ func OAuthLogin(ctx *middleware.Context) {
// create account if missing
if
err
==
m
.
ErrUserNotFound
{
if
setting
.
DisableUserSignUp
{
ctx
.
Redirect
(
setting
.
AppSubUrl
+
"/login"
)
return
}
cmd
:=
m
.
CreateUserCommand
{
Login
:
userInfo
.
Email
,
Email
:
userInfo
.
Email
,
...
...
pkg/api/signup.go
View file @
04d03f73
...
...
@@ -4,10 +4,15 @@ import (
"github.com/torkelo/grafana-pro/pkg/bus"
"github.com/torkelo/grafana-pro/pkg/middleware"
m
"github.com/torkelo/grafana-pro/pkg/models"
"github.com/torkelo/grafana-pro/pkg/setting"
)
// POST /api/user/signup
func
SignUp
(
c
*
middleware
.
Context
,
cmd
m
.
CreateUserCommand
)
{
if
setting
.
DisableUserSignUp
{
c
.
JsonApiErr
(
401
,
"User signup is disabled"
,
nil
)
return
}
cmd
.
Login
=
cmd
.
Email
...
...
pkg/cmd/web.go
View file @
04d03f73
...
...
@@ -36,6 +36,8 @@ var CmdWeb = cli.Command{
}
func
newMacaron
()
*
macaron
.
Macaron
{
macaron
.
Env
=
setting
.
Env
m
:=
macaron
.
New
()
m
.
Use
(
middleware
.
Logger
())
m
.
Use
(
macaron
.
Recovery
())
...
...
pkg/middleware/middleware.go
View file @
04d03f73
...
...
@@ -83,7 +83,7 @@ func GetContextHandler() macaron.Handler {
func
(
ctx
*
Context
)
Handle
(
status
int
,
title
string
,
err
error
)
{
if
err
!=
nil
{
log
.
Error
(
4
,
"%s: %v"
,
title
,
err
)
if
macaron
.
Env
!=
macaron
.
PROD
{
if
setting
.
Env
!=
setting
.
PROD
{
ctx
.
Data
[
"ErrorMsg"
]
=
err
}
}
...
...
pkg/setting/setting.go
View file @
04d03f73
...
...
@@ -63,6 +63,7 @@ var (
LogInRememberDays
int
CookieUserName
string
CookieRememberName
string
DisableUserSignUp
bool
// single account
SingleAccountMode
bool
...
...
@@ -196,6 +197,7 @@ func NewConfigContext() {
LogInRememberDays
=
security
.
Key
(
"login_remember_days"
)
.
MustInt
()
CookieUserName
=
security
.
Key
(
"cookie_username"
)
.
String
()
CookieRememberName
=
security
.
Key
(
"cookie_remember_name"
)
.
String
()
DisableUserSignUp
=
security
.
Key
(
"disable_user_signup"
)
.
MustBool
(
false
)
// admin
AdminUser
=
security
.
Key
(
"admin_user"
)
.
String
()
...
...
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