mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-24 18:10:52 +00:00
Show user OpenID URIs in their profile (#1314)
This commit is contained in:
parent
e1586898b2
commit
9182a35f18
11 changed files with 180 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue