<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<title>Igor Users</title>
	<style>
	table, th, td {
		border: 1px solid black;
		border-collapse: collapse;
	}
	</style>
</head>
<body>
	<h1>Igor Users</h1>

	{% set currentUser = igor.app.getSessionItem('user','') %}
	{% if currentUser %}
		<p>
			You are logged in as {{currentUser}}.
			{% if currentUser != 'admin' %}
				You may not have sufficient permissions for the commands below unless you login as user <i>admin</i>.
			{% endif %}
		</p>
	{% else %}
		<p>
			You are not logged in. This page will probably not render correctly.
		</p>
	{% endif %}
	
	<table style="width:100%">
		<tr>
			<th>Username</th>
			<th>Identity Entry</th>
			<th>People Entry</th>
			<th>Operation</th>
		</tr>
	
		{% set userList = igor.database.getElements('/data/identities/*', 'get', callerToken) %}
		{% for user in userList %}
			{% if not ':' in user.tagName %}
				{% set username = user.tagName %}
				<tr>
					<td>{{username}}</td>
					<td><a href="/data/identities/{{username}}">identities/{{username}}</a></td>
					<td><a href="/data/people/{{username}}">people/{{username}}</a></td>
					<td>
						{% if username != 'admin' and username != currentUser %}
							<a href="_delete.html?username={{username}}">delete</a><br>
						{% endif %}
						<a href="_password.html?username={{username}}">change password</a>
					</td>
				</tr>
			{% endif %}
		{% endfor %}
	</table>
	
	<h1>Add User</h1>
	
	<p>To add a new user:</p>
	<form action="/plugin/user/add">
		<input name="returnTo" type="hidden" value="/plugin/{{pluginName}}/page/index.html">
		Username: <input name="username"><br>
		Password: <input name="password" type="password"></br>
		<input type="submit" value="Add">
	</form>
	
	<hr>
	{% if returnTo %}
		<a href="{{returnTo}}">Return to {{returnTo}}.</a><br>
	{% endif %}
	<a href="/plugin/{{pluginName}}/page/index.html">Return to user listing page.</a><br>
	<a href="/">Return to Igor homepage</a>

</body>
</html>
