Skip to content

Commit

Permalink
Add username to the creator in the front-end (#4753)
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Quandt <[email protected]>
  • Loading branch information
thquad committed Feb 1, 2021
1 parent f11fdc0 commit f20c94e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ export class BaseEndpointsDataSource extends ListDataSource<EndpointModel> {
system_shared_token: false,
metricsAvailable: false,
sso_allowed: false,
creator: {admin:false}
creator: {
name:'',
admin:false
}
}),
paginationKey: action.paginationKey,
isLocal: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<app-meta-card-item *ngIf="enableUserEndpoints$ | async">
<app-meta-card-key>Created by</app-meta-card-key>
<app-meta-card-value>
<div>{{ row.creator.admin ? "Admin" : "User" }}</div>
<div>{{ row.creator.name }}</div>
</app-meta-card-value>
</app-meta-card-item>
<app-meta-card-item [hidden]="!hasDetails">
Expand Down
1 change: 1 addition & 0 deletions src/frontend/packages/store/src/types/endpoint.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export interface EndpointUser {

// Metadata for the user who created an endpoint
export interface CreatorInfo {
name: string;
admin: boolean;
}

Expand Down
4 changes: 4 additions & 0 deletions src/jetstream/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func (p *portalProxy) getInfo(c echo.Context) (*interfaces.Info, error) {

// set the creator preemptively as admin, if no id is found
endpoint.Creator = &interfaces.CreatorInfo{
Name: "admin",
Admin: true,
}

Expand All @@ -110,6 +111,9 @@ func (p *portalProxy) getInfo(c echo.Context) (*interfaces.Info, error) {
u, err := p.StratosAuthService.GetUser(cnsi.Creator)
if err == nil {
endpoint.Creator.Admin = u.Admin
if u.Admin == false {
endpoint.Creator.Name = u.Name
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/jetstream/repository/interfaces/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ type ConnectedUser struct {

// CreatorInfo - additional information about the user who created an endpoint
type CreatorInfo struct {
Admin bool `json:"admin"`
Name string `json:"name"`
Admin bool `json:"admin"`
}

type JWTUserTokenInfo struct {
Expand Down

0 comments on commit f20c94e

Please sign in to comment.