diff options
author | Sandro Santilli <strk@kbt.io> | 2017-03-20 09:31:08 +0100 |
---|---|---|
committer | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2017-03-20 09:31:08 +0100 |
commit | 9182a35f18b6d5cd981486852028e670984145c3 (patch) | |
tree | cab69a27330df5a095de95017e8b40bf13598889 /models/user_openid.go | |
parent | e1586898b2f0905b6f59383c01a3aed6b39de93a (diff) | |
download | gitea-9182a35f18b6d5cd981486852028e670984145c3.tar.gz gitea-9182a35f18b6d5cd981486852028e670984145c3.zip |
Show user OpenID URIs in their profile (#1314)
Diffstat (limited to 'models/user_openid.go')
-rw-r--r-- | models/user_openid.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/models/user_openid.go b/models/user_openid.go index a5c88e9009..18e847d89d 100644 --- a/models/user_openid.go +++ b/models/user_openid.go @@ -21,6 +21,7 @@ type UserOpenID struct { ID int64 `xorm:"pk autoincr"` UID int64 `xorm:"INDEX NOT NULL"` URI string `xorm:"UNIQUE NOT NULL"` + Show bool `xorm:"DEFAULT false"` } // GetUserOpenIDs returns all openid addresses that belongs to given user. @@ -28,6 +29,7 @@ func GetUserOpenIDs(uid int64) ([]*UserOpenID, error) { openids := make([]*UserOpenID, 0, 5) if err := x. Where("uid=?", uid). + Asc("id"). Find(&openids); err != nil { return nil, err } @@ -89,6 +91,12 @@ func DeleteUserOpenID(openid *UserOpenID) (err error) { return nil } +// ToggleUserOpenIDVisibility toggles visibility of an openid address of given user. +func ToggleUserOpenIDVisibility(id int64) (err error) { + _, err = x.Exec("update user_open_id set show = not show where id = ?", id) + return err +} + // GetUserByOpenID returns the user object by given OpenID if exists. func GetUserByOpenID(uri string) (*User, error) { if len(uri) == 0 { |