Memberships: API to add and retrieve user information
             Create user
             Add SSH key
             Ping clients on mutations

Change-Id: I02799b8b4bc88813afeb306cc122a7eaa4496c3c
diff --git a/core/auth/memberships/memberships-tmpl/base.html b/core/auth/memberships/memberships-tmpl/base.html
index 50b792e..9755c08 100644
--- a/core/auth/memberships/memberships-tmpl/base.html
+++ b/core/auth/memberships/memberships-tmpl/base.html
@@ -5,9 +5,17 @@
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>{{ block "title" . }}{{ end }}</title>
     <link rel="stylesheet" href="/static/pico.2.0.6.min.css">
-    <link rel="stylesheet" href="/static/main.css?v=0.0.1">
+    <link rel="stylesheet" href="/static/main.css?v=0.0.3">
 </head>
 <body class="container">
+    {{ define "svgIcon" }}
+    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
+        <g fill="none" fill-rule="evenodd">
+            <path d="M24 0v24H0V0zM12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z" />
+            <path fill="currentColor" d="m12 13.414l5.657 5.657a1 1 0 0 0 1.414-1.414L13.414 12l5.657-5.657a1 1 0 0 0-1.414-1.414L12 10.586L6.343 4.929A1 1 0 0 0 4.93 6.343L10.586 12l-5.657 5.657a1 1 0 1 0 1.414 1.414z" />
+        </g>
+    </svg>
+    {{ end }}
     {{- block "content" . }}
     {{- end }}
     {{ if ne .ErrorMessage "" }}
diff --git a/core/auth/memberships/memberships-tmpl/group.html b/core/auth/memberships/memberships-tmpl/group.html
index 4576a92..c927536 100644
--- a/core/auth/memberships/memberships-tmpl/group.html
+++ b/core/auth/memberships/memberships-tmpl/group.html
@@ -1,16 +1,6 @@
-{{ define "svgIcon" }}
-<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
-    <g fill="none" fill-rule="evenodd">
-        <path d="M24 0v24H0V0zM12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z" />
-        <path fill="currentColor" d="m12 13.414l5.657 5.657a1 1 0 0 0 1.414-1.414L13.414 12l5.657-5.657a1 1 0 0 0-1.414-1.414L12 10.586L6.343 4.929A1 1 0 0 0 4.93 6.343L10.586 12l-5.657 5.657a1 1 0 1 0 1.414 1.414z" />
-    </g>
-</svg>
-{{ end }}
-
 {{ define "title" }}
     Group - {{ .GroupName }}
 {{ end }}
-
 {{ define "content" }}
 {{- $parentGroupName := .GroupName }}
     <div>
diff --git a/core/auth/memberships/memberships-tmpl/user.html b/core/auth/memberships/memberships-tmpl/user.html
index 4d52092..562f27d 100644
--- a/core/auth/memberships/memberships-tmpl/user.html
+++ b/core/auth/memberships/memberships-tmpl/user.html
@@ -2,8 +2,40 @@
     User - {{ .CurrentUser }}
 {{ end }}
 {{- define "content" -}}
+    {{ $currentUser := .CurrentUser }}
+    {{ $isLoggedInUser := .LoggedInUserPage}}
     <h1 class="headline">User: {{ .CurrentUser }}</h1>
+    <p>{{ .Email }}</p>
+    <hr class="divider">
+    <h3>SSH Public keys</h3>
+    <div class="ssh-key-grid">
+        {{ if eq (len .SSHPublicKeys) 0 }}
+            <p>No SSH keys configured.</p>
+        {{ else }}
+            {{ 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?">
+                            <input type="hidden" name="ssh-key" value="{{ . }}">
+                            <button class="remove ssh-remove" type="submit">
+                                <div>{{ template "svgIcon" }}</div>
+                            </button>
+                        </form>
+                    {{ end }}
+                    <div class="ssh-key">{{ . }}</div>
+                </div>
+            {{ end }}
+        {{ end }}
+    </div>
     {{ if .LoggedInUserPage }}
+    <hr class="divider">
+    <form action="/user/{{ .CurrentUser }}/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>
+        </fieldset>
+    </form>
+    <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>
@@ -12,6 +44,7 @@
         </fieldset>
     </form>
     {{ end }}
+    <hr class="divider">
 
     <h3>Owner of groups</h3>
     <div class="user-remove">
@@ -44,4 +77,15 @@
             </a>
         {{- end }}
     </div>
+
+    <dialog id="confirmation" close>
+        <article>
+            <h3>Attention</h3>
+            <p id="confirmation-message">Are you sure?</p>
+            <footer>
+                <button id="cancel-button" class="secondary cancel-button">Cancel</button>
+                <button id="confirm-button">Confirm</button>
+            </footer>
+        </article>
+    </dialog>
 {{- end }}