Memebrships: Refactor Store interface
Use unified memberships table.
Add few internal API endpoints.
Change-Id: I80ac5a0f5c262e04d7898cca571b938a35d68d39
diff --git a/core/auth/memberships/memberships-tmpl/group.html b/core/auth/memberships/memberships-tmpl/group.html
index c927536..c3ff8c7 100644
--- a/core/auth/memberships/memberships-tmpl/group.html
+++ b/core/auth/memberships/memberships-tmpl/group.html
@@ -1,16 +1,20 @@
{{ define "title" }}
- Group - {{ .GroupName }}
+ Group - {{ .Title }}
{{ end }}
{{ define "content" }}
-{{- $parentGroupName := .GroupName }}
+{{- $parentGroupId := .GroupId }}
<div>
- <h2 class="headline">Group: {{ .GroupName }}</h2>
+ <h2 class="headline">Group: {{ .Title }}</h2>
<p class="description">{{ .Description }}</p>
</div>
<hr class="divider">
- <form action="/group/{{ .GroupName }}/add-user/" method="post">
+ <form action="/group/{{ .GroupId }}/add-user/" method="post">
<fieldset class="grid first">
- <input type="text" id="username" name="username" placeholder="username" required>
+ <select id="userId" aria-label="Select" name="userId" required>
+ {{- range .AllUsers }}
+ <option value="{{ .Id }}">{{ .Username }}</option>
+ {{- end }}
+ </select>
<select id="status" name="status" required>
<option value="Member" selected>Member</option>
<option value="Owner">Owner</option>
@@ -18,21 +22,21 @@
<button type="submit">Add Member</button>
</fieldset>
</form>
- <form action="/group/{{ .GroupName }}/add-child-group" method="post">
+ <form action="/group/{{ .GroupId }}/add-child-group" method="post">
<fieldset class="grid twoone">
- <select id="child-group" aria-label="Select" name="child-group" required>
+ <select id="otherId" aria-label="Select" name="otherId" required>
{{- range .AllGroups }}
- <option value="{{ .Name }}">{{ .Name }}</option>
+ <option value="{{ .Id }}">{{ .Title }}</option>
{{- end }}
</select>
<button type="submit">Create Child Group</button>
</fieldset>
</form>
- <form action="/group/{{ .GroupName }}/add-owner-group" method="post">
+ <form action="/group/{{ .GroupId }}/add-owner-group" method="post">
<fieldset class="grid twoone">
- <select id="owner-group" aria-label="Select" name="owner-group" required>
+ <select id="otherId" aria-label="Select" name="otherId" required>
{{- range .AllGroups }}
- <option value="{{ .Name }}">{{ .Name }}</option>
+ <option value="{{ .Id }}">{{ .Title }}</option>
{{- end }}
</select>
<button type="submit">Add Owner Group</button>
@@ -44,8 +48,8 @@
{{- range .Owners }}
<div>
<fieldset role="group">
- <a class="link-button" href="/user/{{ . }}" role="button">{{ . }}</a>
- <form action="/group/{{ $parentGroupName }}/remove-owner/{{ . }}" method="post" class="remove-form" data-confirmation-message="Are you sure you want to revoke user <strong>{{ . }}</strong>'s ownership of the <strong>{{ $parentGroupName }}</strong> group?">
+ <a class="link-button" href="/user/{{ .Id }}" role="button">{{ .Username }}</a>
+ <form action="/group/{{ $parentGroupId }}/remove-owner/{{ .Id }}" method="post" class="remove-form" data-confirmation-message="Are you sure you want to revoke user <strong>{{ .Username }}</strong>'s ownership of the <strong>{{ $parentGroupId }}</strong> group?">
<button class="remove" type="submit" aria-label="Remove owner">
{{ template "svgIcon" }}
</button>
@@ -62,8 +66,8 @@
{{- range .Members }}
<div>
<fieldset role="group">
- <a class="link-button" href="/user/{{ . }}" role="button">{{ . }}</a>
- <form action="/group/{{ $parentGroupName }}/remove-member/{{ . }}" method="post" class="remove-form" data-confirmation-message="Are you sure you want to remove user <strong>{{ . }}</strong> user from <strong>{{ $parentGroupName }}</strong> group?">
+ <a class="link-button" href="/user/{{ .Id }}" role="button">{{ .Username }}</a>
+ <form action="/group/{{ $parentGroupId }}/remove-member/{{ .Id }}" method="post" class="remove-form" data-confirmation-message="Are you sure you want to remove user <strong>{{ .Username }}</strong> user from <strong>{{ $parentGroupId }}</strong> group?">
<button class="remove" type="submit">
{{ template "svgIcon" }}
</button>
@@ -77,9 +81,9 @@
<h3>Transitive Groups</h3>
<div class="user-remove">
{{- range .TransitiveGroups }}
- <a class="link-button" href="/group/{{ .Name }}" role="button"
+ <a class="link-button" href="/group/{{ .Id }}" role="button"
{{ if ne .Description "" }} data-tooltip="{{ .Description }}" data-placement="bottom" {{ end }}>
- {{ .Name }}
+ {{ .Title }}
</a>
{{- end }}
</div>
@@ -90,11 +94,11 @@
{{- range .ChildGroups }}
<div>
<fieldset role="group">
- <a class="link-button" href="/group/{{ .Name }}" role="button"
+ <a class="link-button" href="/group/{{ .Id }}" role="button"
{{ if ne .Description "" }} data-tooltip="{{ .Description }}" data-placement="bottom" {{ end }}>
- {{ .Name }}
+ {{ .Title }}
</a>
- <form action="/group/{{ $parentGroupName }}/remove-child-group/{{ .Name }}" method="post" class="remove-form" data-confirmation-message="Are you sure you want to remove group <strong>{{ .Name }}</strong> as a child of the group <strong>{{ $parentGroupName }}</strong>?">
+ <form action="/group/{{ $parentGroupId }}/remove-child-group/{{ .Id }}" method="post" class="remove-form" data-confirmation-message="Are you sure you want to remove group <strong>{{ .Title }}</strong> as a child of the group <strong>{{ $parentGroupId }}</strong>?">
<button class="remove" type="submit">
{{ template "svgIcon" }}
</button>
@@ -108,9 +112,9 @@
<h3>Owner Groups</h3>
<div class="user-remove">
{{- range .OwnerGroups }}
- <a class="link-button" href="/group/{{ .Name }}" role="button"
+ <a class="link-button" href="/group/{{ .Id }}" role="button"
{{ if ne .Description "" }} data-tooltip="{{ .Description }}" data-placement="bottom" {{ end }}>
- {{ .Name }}
+ {{ .Title }}
</a>
{{- end }}
</div>
diff --git a/core/auth/memberships/memberships-tmpl/user.html b/core/auth/memberships/memberships-tmpl/user.html
index 562f27d..eda7eb5 100644
--- a/core/auth/memberships/memberships-tmpl/user.html
+++ b/core/auth/memberships/memberships-tmpl/user.html
@@ -1,11 +1,11 @@
{{ define "title" }}
- User - {{ .CurrentUser }}
+ User - {{ .User.Username }}
{{ end }}
{{- define "content" -}}
- {{ $currentUser := .CurrentUser }}
+ {{ $currentUserId := .User.Id }}
{{ $isLoggedInUser := .LoggedInUserPage}}
- <h1 class="headline">User: {{ .CurrentUser }}</h1>
- <p>{{ .Email }}</p>
+ <h1 class="headline">User: {{ .User.Username }}</h1>
+ <p>{{ .User.Email }}</p>
<hr class="divider">
<h3>SSH Public keys</h3>
<div class="ssh-key-grid">
@@ -15,7 +15,7 @@
{{ range .SSHPublicKeys }}
<div class="ssh-key-item">
{{ if $isLoggedInUser }}
- <form action="/user/{{ $currentUser }}/remove-ssh-key" method="post" class="remove-form" data-confirmation-message="Are you sure you want to remove SSH key?">
+ <form action="/user/{{ $currentUserId }}/remove-ssh-key" method="post" class="remove-form" data-confirmation-message="Are you sure you want to remove SSH key?">
<input type="hidden" name="ssh-key" value="{{ . }}">
<button class="remove ssh-remove" type="submit">
<div>{{ template "svgIcon" }}</div>
@@ -29,7 +29,7 @@
</div>
{{ if .LoggedInUserPage }}
<hr class="divider">
- <form action="/user/{{ .CurrentUser }}/ssh-key" method="post">
+ <form action="/user/{{ .User.Id }}/ssh-key" method="post">
<fieldset class="grid twoone">
<input type="text" id="ssh-hey" name="ssh-key" placeholder="Add SSH public key..." required>
<button type="submit">Add SSH public key</button>
@@ -38,7 +38,8 @@
<hr class="divider">
<form action="/create-group" method="post">
<fieldset class="grid first">
- <input type="text" id="group-name" name="group-name" placeholder="Group name" required>
+ <input type="text" id="id" name="id" placeholder="Id" required>
+ <input type="text" id="title" name="title" placeholder="Title" required>
<input type="text" id="description" name="description" placeholder="Description">
<button type="submit">Create Group</button>
</fieldset>
@@ -49,9 +50,9 @@
<h3>Owner of groups</h3>
<div class="user-remove">
{{- range .OwnerGroups }}
- <a href="/group/{{ .Name }}" role="button"
+ <a href="/group/{{ .Id }}" role="button"
{{ if ne .Description "" }} data-tooltip="{{ .Description }}" data-placement="bottom" {{ end }}>
- {{ .Name }}
+ {{ .Title }}
</a>
{{- end }}
</div>
@@ -60,9 +61,9 @@
<h3>Direct member of groups</h3>
<div class="user-remove">
{{- range .MembershipGroups }}
- <a href="/group/{{ .Name }}" role="button"
+ <a href="/group/{{ .Id }}" role="button"
{{ if ne .Description "" }} data-tooltip="{{ .Description }}" data-placement="bottom" {{ end }}>
- {{ .Name }}
+ {{ .Title }}
</a>
{{- end }}
</div>
@@ -71,9 +72,9 @@
<h3>Transitive member of groups</h3>
<div class="user-remove">
{{- range .TransitiveGroups -}}
- <a href="/group/{{ .Name }}" role="button"
+ <a href="/group/{{ .Id }}" role="button"
{{ if ne .Description "" }} data-tooltip="{{ .Description }}" data-placement="bottom" {{ end }}>
- {{ .Name }}
+ {{ .Title }}
</a>
{{- end }}
</div>