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
d25624a8
Commit
d25624a8
authored
Aug 27, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(signup): began work on new / alternate signup flow that includes email verification, #2353
parent
7e44a8ed
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
57 additions
and
34 deletions
+57
-34
pkg/api/dtos/user.go
+4
-0
pkg/api/org_invite.go
+2
-2
pkg/api/signup.go
+23
-13
pkg/events/events.go
+8
-0
pkg/metrics/metrics.go
+9
-8
pkg/models/temp_user.go
+1
-0
pkg/services/notifications/notifications.go
+1
-1
pkg/setting/setting.go
+5
-4
public/app/partials/login.html
+0
-2
public/app/partials/signup_invited.html
+1
-1
public/css/less/login.less
+3
-3
No files found.
pkg/api/dtos/user.go
View file @
d25624a8
package
dtos
package
dtos
type
SignUpForm
struct
{
Email
string
`json:"email" binding:"Required"`
}
type
AdminCreateUserForm
struct
{
type
AdminCreateUserForm
struct
{
Email
string
`json:"email"`
Email
string
`json:"email"`
Login
string
`json:"login"`
Login
string
`json:"login"`
...
...
pkg/api/org_invite.go
View file @
d25624a8
...
@@ -171,7 +171,7 @@ func CompleteInvite(c *middleware.Context, completeInvite dtos.CompleteInviteFor
...
@@ -171,7 +171,7 @@ func CompleteInvite(c *middleware.Context, completeInvite dtos.CompleteInviteFor
user
:=
cmd
.
Result
user
:=
cmd
.
Result
bus
.
Publish
(
&
events
.
UserSignedUp
{
bus
.
Publish
(
&
events
.
SignUpCompleted
{
Id
:
user
.
Id
,
Id
:
user
.
Id
,
Name
:
user
.
Name
,
Name
:
user
.
Name
,
Email
:
user
.
Email
,
Email
:
user
.
Email
,
...
@@ -199,7 +199,7 @@ func CompleteInvite(c *middleware.Context, completeInvite dtos.CompleteInviteFor
...
@@ -199,7 +199,7 @@ func CompleteInvite(c *middleware.Context, completeInvite dtos.CompleteInviteFor
loginUserWithUser
(
&
user
,
c
)
loginUserWithUser
(
&
user
,
c
)
metrics
.
M_Api_User_SignUp
.
Inc
(
1
)
metrics
.
M_Api_User_SignUp
Completed
.
Inc
(
1
)
metrics
.
M_Api_User_SignUpInvite
.
Inc
(
1
)
metrics
.
M_Api_User_SignUpInvite
.
Inc
(
1
)
return
ApiSuccess
(
"User created and logged in"
)
return
ApiSuccess
(
"User created and logged in"
)
...
...
pkg/api/signup.go
View file @
d25624a8
package
api
package
api
import
(
import
(
"github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/events"
"github.com/grafana/grafana/pkg/events"
"github.com/grafana/grafana/pkg/metrics"
"github.com/grafana/grafana/pkg/metrics"
"github.com/grafana/grafana/pkg/middleware"
"github.com/grafana/grafana/pkg/middleware"
m
"github.com/grafana/grafana/pkg/models"
m
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/util"
)
)
// POST /api/user/signup
// POST /api/user/signup
func
SignUp
(
c
*
middleware
.
Context
,
cmd
m
.
CreateUserCommand
)
Response
{
func
SignUp
(
c
*
middleware
.
Context
,
form
dtos
.
SignUpForm
)
Response
{
if
!
setting
.
AllowUserSignUp
{
if
!
setting
.
AllowUserSignUp
{
return
ApiError
(
401
,
"User signup is disabled"
,
nil
)
return
ApiError
(
401
,
"User signup is disabled"
,
nil
)
}
}
cmd
.
Login
=
cmd
.
Email
existing
:=
m
.
GetUserByLoginQuery
{
LoginOrEmail
:
form
.
Email
}
if
err
:=
bus
.
Dispatch
(
&
existing
);
err
==
nil
{
return
ApiError
(
401
,
"User with same email address already exists"
,
nil
)
}
cmd
:=
m
.
CreateTempUserCommand
{}
cmd
.
OrgId
=
-
1
cmd
.
Email
=
form
.
Email
cmd
.
Status
=
m
.
TmpUserSignUpStarted
cmd
.
InvitedByUserId
=
c
.
UserId
cmd
.
Code
=
util
.
GetRandomString
(
10
)
cmd
.
RemoteAddr
=
c
.
Req
.
RemoteAddr
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
return
ApiError
(
500
,
"
failed to create user
"
,
err
)
return
ApiError
(
500
,
"
Failed to create signup
"
,
err
)
}
}
user
:=
cmd
.
Result
// user := cmd.Resu
bus
.
Publish
(
&
events
.
UserSignedUp
{
Id
:
user
.
Id
,
Name
:
user
.
Name
,
Email
:
user
.
Email
,
Login
:
user
.
Login
,
})
loginUserWithUser
(
&
user
,
c
)
bus
.
Publish
(
&
events
.
UserSignedUp
{
Email
:
form
.
Email
}
)
metrics
.
M_Api_User_SignUp
.
Inc
(
1
)
//
// loginUserWithUser(&user, c)
//
//
metrics
.
M_Api_User_SignUpStarted
.
Inc
(
1
)
return
ApiSuccess
(
"User created and logged in"
)
return
ApiSuccess
(
"User created and logged in"
)
}
}
pkg/events/events.go
View file @
d25624a8
...
@@ -78,6 +78,14 @@ type UserSignedUp struct {
...
@@ -78,6 +78,14 @@ type UserSignedUp struct {
Email
string
`json:"email"`
Email
string
`json:"email"`
}
}
type
SignUpCompleted
struct
{
Timestamp
time
.
Time
`json:"timestamp"`
Id
int64
`json:"id"`
Name
string
`json:"name"`
Login
string
`json:"login"`
Email
string
`json:"email"`
}
type
UserUpdated
struct
{
type
UserUpdated
struct
{
Timestamp
time
.
Time
`json:"timestamp"`
Timestamp
time
.
Time
`json:"timestamp"`
Id
int64
`json:"id"`
Id
int64
`json:"id"`
...
...
pkg/metrics/metrics.go
View file @
d25624a8
...
@@ -13,14 +13,15 @@ var (
...
@@ -13,14 +13,15 @@ var (
M_Api_Status_500
=
NewComboCounterRef
(
"api.status.500"
)
M_Api_Status_500
=
NewComboCounterRef
(
"api.status.500"
)
M_Api_Status_404
=
NewComboCounterRef
(
"api.status.404"
)
M_Api_Status_404
=
NewComboCounterRef
(
"api.status.404"
)
M_Api_User_SignUp
=
NewComboCounterRef
(
"api.user.signup"
)
M_Api_User_SignUpStarted
=
NewComboCounterRef
(
"api.user.signup_started"
)
M_Api_User_SignUpInvite
=
NewComboCounterRef
(
"api.user.signup_invite"
)
M_Api_User_SignUpCompleted
=
NewComboCounterRef
(
"api.user.signup_completed"
)
M_Api_Dashboard_Get
=
NewComboCounterRef
(
"api.dashboard.get"
)
M_Api_User_SignUpInvite
=
NewComboCounterRef
(
"api.user.signup_invite"
)
M_Api_Dashboard_Post
=
NewComboCounterRef
(
"api.dashboard.post"
)
M_Api_Dashboard_Get
=
NewComboCounterRef
(
"api.dashboard.get"
)
M_Api_Admin_User_Create
=
NewComboCounterRef
(
"api.admin.user_create"
)
M_Api_Dashboard_Post
=
NewComboCounterRef
(
"api.dashboard.post"
)
M_Api_Login_Post
=
NewComboCounterRef
(
"api.login.post"
)
M_Api_Admin_User_Create
=
NewComboCounterRef
(
"api.admin.user_create"
)
M_Api_Login_OAuth
=
NewComboCounterRef
(
"api.login.oauth"
)
M_Api_Login_Post
=
NewComboCounterRef
(
"api.login.post"
)
M_Api_Org_Create
=
NewComboCounterRef
(
"api.org.create"
)
M_Api_Login_OAuth
=
NewComboCounterRef
(
"api.login.oauth"
)
M_Api_Org_Create
=
NewComboCounterRef
(
"api.org.create"
)
M_Api_Dashboard_Snapshot_Create
=
NewComboCounterRef
(
"api.dashboard_snapshot.create"
)
M_Api_Dashboard_Snapshot_Create
=
NewComboCounterRef
(
"api.dashboard_snapshot.create"
)
M_Api_Dashboard_Snapshot_External
=
NewComboCounterRef
(
"api.dashboard_snapshot.external"
)
M_Api_Dashboard_Snapshot_External
=
NewComboCounterRef
(
"api.dashboard_snapshot.external"
)
...
...
pkg/models/temp_user.go
View file @
d25624a8
...
@@ -13,6 +13,7 @@ var (
...
@@ -13,6 +13,7 @@ var (
type
TempUserStatus
string
type
TempUserStatus
string
const
(
const
(
TmpUserSignUpStarted
TempUserStatus
=
"SignUpStarted"
TmpUserInvitePending
TempUserStatus
=
"InvitePending"
TmpUserInvitePending
TempUserStatus
=
"InvitePending"
TmpUserCompleted
TempUserStatus
=
"Completed"
TmpUserCompleted
TempUserStatus
=
"Completed"
TmpUserEmailPending
TempUserStatus
=
"EmailPending"
TmpUserEmailPending
TempUserStatus
=
"EmailPending"
...
...
pkg/services/notifications/notifications.go
View file @
d25624a8
...
@@ -131,7 +131,7 @@ func userSignedUpHandler(evt *events.UserSignedUp) error {
...
@@ -131,7 +131,7 @@ func userSignedUpHandler(evt *events.UserSignedUp) error {
To
:
[]
string
{
evt
.
Email
},
To
:
[]
string
{
evt
.
Email
},
Template
:
tmplWelcomeOnSignUp
,
Template
:
tmplWelcomeOnSignUp
,
Data
:
map
[
string
]
interface
{}{
Data
:
map
[
string
]
interface
{}{
"
Name"
:
evt
.
Login
,
"
Email"
:
evt
.
Email
,
},
},
})
})
}
}
pkg/setting/setting.go
View file @
d25624a8
...
@@ -75,10 +75,11 @@ var (
...
@@ -75,10 +75,11 @@ var (
EmailCodeValidMinutes
int
EmailCodeValidMinutes
int
// User settings
// User settings
AllowUserSignUp
bool
AllowUserSignUp
bool
AllowUserOrgCreate
bool
AllowUserOrgCreate
bool
AutoAssignOrg
bool
AutoAssignOrg
bool
AutoAssignOrgRole
string
AutoAssignOrgRole
string
RequireEmailValidation
bool
// Http auth
// Http auth
AdminUser
string
AdminUser
string
...
...
public/app/partials/login.html
View file @
d25624a8
<div
class=
"container"
>
<div
class=
"container"
>
<div
class=
"login-page-background"
>
</div>
<div
class=
"login-box"
>
<div
class=
"login-box"
>
...
...
public/app/partials/signup_invited.html
View file @
d25624a8
<div
class=
"container"
>
<div
class=
"container"
>
<div
class=
"
login
-page-background"
>
<div
class=
"
signup
-page-background"
>
</div>
</div>
<div
class=
"login-box"
>
<div
class=
"login-box"
>
...
...
public/css/less/login.less
View file @
d25624a8
...
@@ -93,7 +93,7 @@
...
@@ -93,7 +93,7 @@
}
}
}
}
.
login
-page-background {
.
signup
-page-background {
position: fixed;
position: fixed;
top: 0;
top: 0;
left: 0;
left: 0;
...
@@ -101,8 +101,8 @@
...
@@ -101,8 +101,8 @@
bottom: 0;
bottom: 0;
height: 100%;
height: 100%;
width: 100%;
width: 100%;
background-image: url(/img/background_tease.jpg);
background-image: url(
..
/img/background_tease.jpg);
opacity: 0.
05
;
opacity: 0.
3
;
z-index: -1;
z-index: -1;
}
}
...
...
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