当前位置: 首页>>代码示例>>Golang>>正文


Golang models.GetSignedInUserQuery类代码示例

本文整理汇总了Golang中github.com/grafana/grafana/pkg/models.GetSignedInUserQuery的典型用法代码示例。如果您正苦于以下问题:Golang GetSignedInUserQuery类的具体用法?Golang GetSignedInUserQuery怎么用?Golang GetSignedInUserQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GetSignedInUserQuery类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: getSignedInUserQueryForProxyAuth

func getSignedInUserQueryForProxyAuth(headerVal string) *m.GetSignedInUserQuery {
	query := m.GetSignedInUserQuery{}
	if setting.AuthProxyHeaderProperty == "username" {
		query.Login = headerVal
	} else if setting.AuthProxyHeaderProperty == "email" {
		query.Email = headerVal
	} else {
		panic("Auth proxy header property invalid")
	}
	return &query
}
开发者ID:AlexAkulov,项目名称:grafana,代码行数:11,代码来源:auth_proxy.go

示例2: GetSignedInUser

func GetSignedInUser(query *m.GetSignedInUserQuery) error {
	var rawSql = `SELECT
	                u.id           as user_id,
	                u.is_admin     as is_grafana_admin,
	                u.email        as email,
	                u.login        as login,
									u.name         as name,
									u.help_flags1  as help_flags1,
	                org.name       as org_name,
	                org_user.role  as org_role,
	                org.id         as org_id
	                FROM ` + dialect.Quote("user") + ` as u
									LEFT OUTER JOIN org_user on org_user.org_id = u.org_id and org_user.user_id = u.id
	                LEFT OUTER JOIN org on org.id = u.org_id `

	sess := x.Table("user")
	if query.UserId > 0 {
		sess.Sql(rawSql+"WHERE u.id=?", query.UserId)
	} else if query.Login != "" {
		sess.Sql(rawSql+"WHERE u.login=?", query.Login)
	} else if query.Email != "" {
		sess.Sql(rawSql+"WHERE u.email=?", query.Email)
	}

	var user m.SignedInUser
	has, err := sess.Get(&user)
	if err != nil {
		return err
	} else if !has {
		return m.ErrUserNotFound
	}

	if user.OrgRole == "" {
		user.OrgId = -1
		user.OrgName = "Org missing"
	}

	query.Result = &user
	return err
}
开发者ID:CamJN,项目名称:grafana,代码行数:40,代码来源:user.go


注:本文中的github.com/grafana/grafana/pkg/models.GetSignedInUserQuery类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。