<template name="userEdit">
	{{#unless canEditOrAdd}}
		<p class="secondary-font-color">{{_ "You_are_not_authorized_to_view_this_page"}}</p>
	{{else}}
		<div class="about clearfix">
			<form class="edit-form" autocomplete="off">
				{{#if user}}
					<h3>{{user.name}}</h3>
				{{else}}
					<h3>{{_ "Add_User"}}</h3>
				{{/if}}
				<div class="input-line">
					<label for="name">{{_ "Name"}}</label>
					<input type="text" id="name" autocomplete="off" value="{{user.name}}">
				</div>
				<div class="input-line">
					<label for="username">{{_ "Username"}}</label>
					<input type="text" id="username" autocomplete="off" value="{{user.username}}">
				</div>
				<div class="input-line">
					<label for="email">{{_ "Email"}}</label>
					<input type="email" id="email" autocomplete="off" value="{{user.emails.[0].address}}">
				</div>
				<div class="input-line">
					<label for="verified">
						<input type="checkbox" id="verified" value="1" checked="{{user.emails.[0].verified}}">
						{{_ "Verified"}}
					</label>
				</div>
				{{#if hasPermission 'edit-other-user-password'}}
					<div class="input-line">
						<label for="password">{{_ "Password"}}</label>
						<input type="password" id="password" autocomplete="off" value="">
						<button id="randomPassword" class="button">{{_ 'Random'}}</button>
					</div>
					<div class="input-line">
						<label for="changePassword">
							<input type="checkbox" id="changePassword" value="1" checked="{{requirePasswordChange}}">
							{{_ "Require_password_change"}}
						</label>
					</div>
				{{/if}}
				{{#unless user}}
					<div class="input-line">
						<label for="role">{{_ "Role"}}</label>
						<select id="role">
							{{#each role}}
								<option value="{{_id}}" selected="{{selectUserRole}}">{{name}}</option>
							{{/each}}
						</select>
					</div>
					<div class="input-line">
						<label for="joinDefaultChannels">
							<input type="checkbox" id="joinDefaultChannels" value="1" checked="true">
							{{_ "Join_default_channels"}}
						</label>
					</div>
					<div class="input-line">
						<label for="sendWelcomeEmail">
							<input type="checkbox" id="sendWelcomeEmail" value="1" checked="true">
							{{_ "Send_welcome_email"}}
						</label>
					</div>
				{{/unless}}
				<nav>
					<button class='button button-block cancel' type="button"><span>{{_ "Cancel"}}</span></button>
					<button class='button button-block primary save'><span>{{_ "Save"}}</span></button>
				</nav>
			</form>
		</div>
	{{/unless}}
</template>
