本文整理汇总了Golang中github.com/grafana/grafana/pkg/models.CreateTempUserCommand类的典型用法代码示例。如果您正苦于以下问题:Golang CreateTempUserCommand类的具体用法?Golang CreateTempUserCommand怎么用?Golang CreateTempUserCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CreateTempUserCommand类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: AddOrgInvite
func AddOrgInvite(c *middleware.Context, inviteDto dtos.AddInviteForm) Response {
logger := log.New("main")
logger.Info(" AddOrgInvite1", c.OrgId)
if !inviteDto.Role.IsValid() {
return ApiError(400, "Invalid role specified", nil)
}
// first try get existing user
userQuery := m.GetUserByLoginQuery{LoginOrEmail: inviteDto.LoginOrEmail}
if err := bus.Dispatch(&userQuery); err != nil {
if err != m.ErrUserNotFound {
return ApiError(500, "Failed to query db for existing user check", err)
}
} else {
return inviteExistingUserToOrg(c, userQuery.Result, &inviteDto)
}
logger1 := log.New("main")
logger1.Info(" AddOrgInvite2", c.OrgId)
cmd := m.CreateTempUserCommand{}
cmd.OrgId = c.OrgId
cmd.Email = inviteDto.LoginOrEmail
cmd.Name = inviteDto.Name
cmd.Status = m.TmpUserInvitePending
cmd.InvitedByUserId = c.UserId
cmd.Code = util.GetRandomString(30)
cmd.Role = inviteDto.Role
cmd.RemoteAddr = c.Req.RemoteAddr
if err := bus.Dispatch(&cmd); err != nil {
return ApiError(500, "Failed to save invite to database", err)
}
// send invite email
if !inviteDto.SkipEmails && util.IsEmail(inviteDto.LoginOrEmail) {
emailCmd := m.SendEmailCommand{
To: []string{inviteDto.LoginOrEmail},
Template: "new_user_invite.html",
Data: map[string]interface{}{
"Name": util.StringsFallback2(cmd.Name, cmd.Email),
"OrgName": c.OrgName,
"Email": c.Email,
"LinkUrl": setting.ToAbsUrl("invite/" + cmd.Code),
"InvitedBy": util.StringsFallback3(c.Name, c.Email, c.Login),
},
}
if err := bus.Dispatch(&emailCmd); err != nil {
return ApiError(500, "Failed to send email invite", err)
}
return ApiSuccess(fmt.Sprintf("Sent invite to %s", inviteDto.LoginOrEmail))
}
return ApiSuccess(fmt.Sprintf("Created invite for %s", inviteDto.LoginOrEmail))
}
开发者ID:yuvaraj951,项目名称:icongrafana,代码行数:55,代码来源:org_invite.go
示例2: CreateTempUser
func CreateTempUser(cmd *m.CreateTempUserCommand) error {
return inTransaction2(func(sess *session) error {
// create user
user := &m.TempUser{
Email: cmd.Email,
Name: cmd.Name,
OrgId: cmd.OrgId,
Code: cmd.Code,
Role: cmd.Role,
Status: cmd.Status,
RemoteAddr: cmd.RemoteAddr,
InvitedByUserId: cmd.InvitedByUserId,
Created: time.Now(),
Updated: time.Now(),
}
if _, err := sess.Insert(user); err != nil {
return err
}
cmd.Result = user
return nil
})
}
开发者ID:nicrioux,项目名称:grafana,代码行数:25,代码来源:temp_user.go
示例3: SignUp
// POST /api/user/signup
func SignUp(c *middleware.Context, form dtos.SignUpForm) Response {
if !setting.AllowUserSignUp {
return ApiError(401, "User signup is disabled", nil)
}
existing := m.GetUserByLoginQuery{LoginOrEmail: form.Email}
if err := bus.Dispatch(&existing); err == nil {
return ApiError(422, "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(20)
cmd.RemoteAddr = c.Req.RemoteAddr
if err := bus.Dispatch(&cmd); err != nil {
return ApiError(500, "Failed to create signup", err)
}
bus.Publish(&events.SignUpStarted{
Email: form.Email,
Code: cmd.Code,
})
metrics.M_Api_User_SignUpStarted.Inc(1)
return Json(200, util.DynMap{"status": "SignUpCreated"})
}
开发者ID:xaka,项目名称:grafana,代码行数:32,代码来源:signup.go
注:本文中的github.com/grafana/grafana/pkg/models.CreateTempUserCommand类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论