mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 05:57:57 +01:00
Closes #85: UI for login as guest
This commit is contained in:
parent
d7865cfaf0
commit
7a7cbd570c
@ -331,7 +331,7 @@ public class UserResource extends BaseResource {
|
||||
// Get the user
|
||||
UserDao userDao = new UserDao();
|
||||
User user = null;
|
||||
if (username.equals(Constants.GUEST_USER_ID)) {
|
||||
if (Constants.GUEST_USER_ID.equals(username)) {
|
||||
if (ConfigUtil.getConfigBooleanValue(ConfigType.GUEST_LOGIN)) {
|
||||
// Login as guest
|
||||
user = userDao.getActiveByUsername(Constants.GUEST_USER_ID);
|
||||
|
@ -106,12 +106,12 @@ angular.module('docs',
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('settings.theme', {
|
||||
url: '/theme',
|
||||
.state('settings.config', {
|
||||
url: '/config',
|
||||
views: {
|
||||
'settings': {
|
||||
templateUrl: 'partial/docs/settings.theme.html',
|
||||
controller: 'SettingsTheme'
|
||||
templateUrl: 'partial/docs/settings.config.html',
|
||||
controller: 'SettingsConfig'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -3,12 +3,24 @@
|
||||
/**
|
||||
* Login controller.
|
||||
*/
|
||||
angular.module('docs').controller('Login', function($scope, $rootScope, $state, $dialog, User) {
|
||||
angular.module('docs').controller('Login', function(Restangular, $scope, $rootScope, $state, $dialog, User) {
|
||||
$scope.codeRequired = false;
|
||||
|
||||
/**
|
||||
* Login.
|
||||
*/
|
||||
// Get the app configuration
|
||||
Restangular.one('app').get().then(function(data) {
|
||||
$scope.app = data;
|
||||
});
|
||||
|
||||
// Login as guest
|
||||
$scope.loginAsGuest = function() {
|
||||
$scope.user = {
|
||||
username: 'guest',
|
||||
password: ''
|
||||
};
|
||||
$scope.login();
|
||||
};
|
||||
|
||||
// Login
|
||||
$scope.login = function() {
|
||||
User.login($scope.user).then(function() {
|
||||
User.userInfo(true).then(function(data) {
|
||||
|
@ -1,9 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Settings theme page controller.
|
||||
* Settings config page controller.
|
||||
*/
|
||||
angular.module('docs').controller('SettingsTheme', function($scope, $rootScope, Restangular) {
|
||||
angular.module('docs').controller('SettingsConfig', function($scope, $rootScope, Restangular) {
|
||||
// Get the app configuration
|
||||
Restangular.one('app').get().then(function(data) {
|
||||
$scope.app = data;
|
||||
});
|
||||
|
||||
// Enable/disable guest login
|
||||
$scope.changeGuestLogin = function(enabled) {
|
||||
Restangular.one('app').post('guest_login', {
|
||||
enabled: enabled
|
||||
}).then(function() {
|
||||
$scope.app.guest_login = enabled;
|
||||
});
|
||||
};
|
||||
|
||||
// Fetch the current theme configuration
|
||||
Restangular.one('theme').get().then(function(data) {
|
||||
$scope.theme = data;
|
@ -60,7 +60,7 @@
|
||||
<script src="app/docs/controller/settings/Settings.js" type="text/javascript"></script>
|
||||
<script src="app/docs/controller/settings/SettingsDefault.js" type="text/javascript"></script>
|
||||
<script src="app/docs/controller/settings/SettingsAccount.js" type="text/javascript"></script>
|
||||
<script src="app/docs/controller/settings/SettingsTheme.js" type="text/javascript"></script>
|
||||
<script src="app/docs/controller/settings/SettingsConfig.js" type="text/javascript"></script>
|
||||
<script src="app/docs/controller/settings/SettingsSecurity.js" type="text/javascript"></script>
|
||||
<script src="app/docs/controller/settings/SettingsSecurityModalDisableTotp.js" type="text/javascript"></script>
|
||||
<script src="app/docs/controller/settings/SettingsSession.js" type="text/javascript"></script>
|
||||
@ -125,12 +125,13 @@
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#/settings/account" title="Logged in as {{ userInfo.username }}">
|
||||
<a href="{{ userInfo.username == 'guest' ? '#/user/guest' : '#/settings/account' }}"
|
||||
title="Logged in as {{ userInfo.username }}">
|
||||
<span class="glyphicon glyphicon-user"></span>
|
||||
{{ userInfo.username }}
|
||||
</a>
|
||||
</li>
|
||||
<li ng-class="{active: $uiRoute}" ui-route="/settings.*">
|
||||
<li ng-class="{active: $uiRoute}" ui-route="/settings.*" ng-show="userInfo.username != 'guest'">
|
||||
<a href="#/settings/account">
|
||||
<span class="glyphicon glyphicon-cog"></span> Settings
|
||||
</a>
|
||||
|
@ -35,6 +35,12 @@
|
||||
<button type="submit" class="btn btn-primary btn-block" ng-click="login()">
|
||||
<span class="glyphicon glyphicon-ok"></span> Sign in
|
||||
</button>
|
||||
|
||||
<p class="text-center lead" ng-if="app.guest_login"> </p>
|
||||
|
||||
<button type="submit" class="btn btn-default btn-block" ng-if="app.guest_login" ng-click="loginAsGuest()">
|
||||
<span class="glyphicon glyphicon-user"></span> Login as guest
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
@ -1,3 +1,18 @@
|
||||
<h1>
|
||||
Guest <small>access</small>
|
||||
<span class="label" ng-class="{ 'label-success': app.guest_login, 'label-danger': !app.guest_login }">
|
||||
{{ app.guest_login ? 'Enabled' : 'Disabled' }}
|
||||
</span>
|
||||
</h1>
|
||||
<p>
|
||||
Guest access is a mode where anyone can access {{ appName }} without password.<br/>
|
||||
Like a normal user, the guest user can only access its documents and those accessible through permissions.<br/>
|
||||
</p>
|
||||
<div ng-if="app">
|
||||
<button ng-if="!app.guest_login" class="btn btn-primary" ng-click="changeGuestLogin(true)">Enable guest access</button>
|
||||
<button ng-if="app.guest_login" class="btn btn-danger" ng-click="changeGuestLogin(false)">Disable guest access</button>
|
||||
</div>
|
||||
|
||||
<h1>Theme <small>customization</small></h1>
|
||||
<form class="form-horizontal" name="editColorForm" novalidate>
|
||||
<div class="form-group">
|
@ -9,14 +9,14 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading" ng-show="isAdmin"><strong>General settings</strong></div>
|
||||
<div class="panel panel-default" ng-show="isAdmin">
|
||||
<div class="panel-heading"><strong>General settings</strong></div>
|
||||
<ul class="list-group">
|
||||
<a class="list-group-item" ng-show="isAdmin" ng-class="{active: $uiRoute}" ui-route="/settings/user.*" href="#/settings/user">Users</a>
|
||||
<a class="list-group-item" ng-show="isAdmin" ng-class="{active: $uiRoute}" ui-route="/settings/group.*" href="#/settings/group">Groups</a>
|
||||
<a class="list-group-item" ng-show="isAdmin" ng-class="{active: $uiRoute}" ui-route="/settings/vocabulary.*" href="#/settings/vocabulary">Vocabularies</a>
|
||||
<a class="list-group-item" ng-show="isAdmin" ng-class="{active: $uiRoute}" ui-route="/settings/theme" href="#/settings/theme">Theme</a>
|
||||
<a class="list-group-item" ng-show="isAdmin" ng-class="{active: $uiRoute}" ui-route="/settings/log" href="#/settings/log">Server logs</a>
|
||||
<a class="list-group-item" ng-class="{active: $uiRoute}" ui-route="/settings/user.*" href="#/settings/user">Users</a>
|
||||
<a class="list-group-item" ng-class="{active: $uiRoute}" ui-route="/settings/group.*" href="#/settings/group">Groups</a>
|
||||
<a class="list-group-item" ng-class="{active: $uiRoute}" ui-route="/settings/vocabulary.*" href="#/settings/vocabulary">Vocabularies</a>
|
||||
<a class="list-group-item" ng-class="{active: $uiRoute}" ui-route="/settings/config" href="#/settings/config">Configuration</a>
|
||||
<a class="list-group-item" ng-class="{active: $uiRoute}" ui-route="/settings/log" href="#/settings/log">Server logs</a>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -62,7 +62,7 @@
|
||||
<span class="help-block" ng-show="editUserForm.storage_quota.$error.pattern">Number required</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" ng-class="{ 'has-error': !editUserForm.password.$valid, success: editUserForm.password.$valid }">
|
||||
<div class="form-group" ng-if="user.username != 'guest'" ng-class="{ 'has-error': !editUserForm.password.$valid, success: editUserForm.password.$valid }">
|
||||
<label class="col-sm-2 control-label" for="inputPassword">Password</label>
|
||||
|
||||
<div class="col-sm-7">
|
||||
@ -76,7 +76,7 @@
|
||||
<span class="help-block" ng-show="editUserForm.password.$error.maxlength">Too long</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" ng-class="{ 'has-error': !editUserForm.passwordconfirm.$valid, success: editUserForm.passwordconfirm.$valid }">
|
||||
<div class="form-group" ng-if="user.username != 'guest'" ng-class="{ 'has-error': !editUserForm.passwordconfirm.$valid, success: editUserForm.passwordconfirm.$valid }">
|
||||
<label class="col-sm-2 -label" for="inputPasswordConfirm">Password (confirm)</label>
|
||||
|
||||
<div class="col-sm-7">
|
||||
@ -94,7 +94,7 @@
|
||||
<button type="submit" class="btn btn-primary" ng-click="edit()" ng-disabled="!editUserForm.$valid">
|
||||
<span class="glyphicon glyphicon-pencil"></span> {{ isEdit() ? 'Edit' : 'Add' }}
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger" ng-click="remove()" ng-show="isEdit()">
|
||||
<button type="button" class="btn btn-danger" ng-click="remove()" ng-show="isEdit() && user.username != 'guest'">
|
||||
<span class="glyphicon glyphicon-trash"></span> Delete
|
||||
</button>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user