Skip to content

Commit

Permalink
Use email as displayname for external users opening WOPI apps
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern committed Jun 17, 2022
1 parent 1ace372 commit cafe46f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions pkg/app/provider/wopi/wopi.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,24 @@ func (p *wopiProvider) GetAppURL(ctx context.Context, resource *provider.Resourc

u, ok := ctxpkg.ContextGetUser(ctx)
if ok { // else defaults to "Guest xyz"
if u.Id.Type == userpb.UserType_USER_TYPE_LIGHTWEIGHT || u.Id.Type == userpb.UserType_USER_TYPE_FEDERATED {
q.Add("userid", resource.Owner.OpaqueId+"@"+resource.Owner.Idp)
} else {
q.Add("userid", u.Id.OpaqueId+"@"+u.Id.Idp)
}
var isPublicShare bool
if u.Opaque != nil {
if _, ok := u.Opaque.Map["public-share-role"]; ok {
isPublicShare = true
}
}

if !isPublicShare {
q.Add("username", u.Username)
if u.Id.Type == userpb.UserType_USER_TYPE_LIGHTWEIGHT || u.Id.Type == userpb.UserType_USER_TYPE_FEDERATED {
q.Add("userid", resource.Owner.OpaqueId+"@"+resource.Owner.Idp)
if !isPublicShare {
// for visual display, federated/external accounts are shown with their email but act on behalf of the owner
q.Add("username", u.Mail)
}
} else {
q.Add("userid", u.Id.OpaqueId+"@"+u.Id.Idp)
if !isPublicShare {
q.Add("username", u.Username)
}
}
}

Expand Down

0 comments on commit cafe46f

Please sign in to comment.