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
9e6df378
Commit
9e6df378
authored
Jan 20, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
worked on account creation
parent
eec17845
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
3 deletions
+38
-3
grafana
+1
-1
pkg/api/account.go
+18
-0
pkg/api/api.go
+1
-0
pkg/models/account.go
+3
-1
pkg/services/sqlstore/account.go
+15
-1
No files found.
grafana
@
9667f324
Subproject commit
d9a33680a686ac6bc1239797278ad03b3c784d1c
Subproject commit
9667f324f1db66f7cdfa7ce5b6c9b38c92f41d53
pkg/api/account.go
0 → 100644
View file @
9e6df378
package
api
import
(
"github.com/torkelo/grafana-pro/pkg/bus"
"github.com/torkelo/grafana-pro/pkg/middleware"
m
"github.com/torkelo/grafana-pro/pkg/models"
)
func
CreateAccount
(
c
*
middleware
.
Context
,
cmd
m
.
CreateAccountCommand
)
{
cmd
.
UserId
=
c
.
UserId
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Failed to create account"
,
nil
)
return
}
c
.
JsonOK
(
"Account created"
)
}
pkg/api/api.go
View file @
9e6df378
...
...
@@ -49,6 +49,7 @@ func Register(r *macaron.Macaron) {
// account
r
.
Group
(
"/account"
,
func
()
{
r
.
Put
(
"/"
,
bind
(
m
.
CreateAccountCommand
{}),
CreateAccount
)
r
.
Put
(
"/users"
,
bind
(
m
.
AddAccountUserCommand
{}),
AddAccountUser
)
r
.
Get
(
"/users"
,
GetAccountUsers
)
r
.
Delete
(
"/users/:id"
,
RemoveAccountUser
)
...
...
pkg/models/account.go
View file @
9e6df378
...
...
@@ -21,8 +21,10 @@ type Account struct {
// COMMANDS
type
CreateAccountCommand
struct
{
Name
string
`json:"name"`
Name
string
`json:"name"
binding:"Required"
`
// initial admin user for account
UserId
int64
`json:"-"`
Result
Account
`json:"-"`
}
...
...
pkg/services/sqlstore/account.go
View file @
9e6df378
...
...
@@ -24,8 +24,22 @@ func CreateAccount(cmd *m.CreateAccountCommand) error {
Updated
:
time
.
Now
(),
}
_
,
err
:=
sess
.
Insert
(
&
account
)
if
_
,
err
:=
sess
.
Insert
(
&
account
);
err
!=
nil
{
return
err
}
// create inital admin account user
user
:=
m
.
AccountUser
{
AccountId
:
account
.
Id
,
UserId
:
cmd
.
UserId
,
Role
:
m
.
ROLE_ADMIN
,
Created
:
time
.
Now
(),
Updated
:
time
.
Now
(),
}
_
,
err
:=
sess
.
Insert
(
&
user
)
cmd
.
Result
=
account
return
err
})
}
...
...
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