Commit 76c58484 authored by Sascha's avatar Sascha

Merge branch 'develop' into 'master'

Preparing v1.11.2

Closes #103 and #87

See merge request !113
parents d51067f8 53a5cc25
......@@ -57,7 +57,7 @@
</div>
<form name="activationForm" ng-if="!success" autocomplete="off">
<form name="activationForm" ng-if="!success && !is_logged_in" autocomplete="off">
<div class="form-group">
<textarea rows="3" class="form-control" id="activationKey" placeholder="{{'KEY' | translate}}" ng-model="activationFormKey" required></textarea>
</div>
......@@ -86,6 +86,15 @@
</div>
</form>
<div ng-if="is_logged_in">
<div class="form-group alert alert-info">
<strong>{{'INFO' | translate}}!</strong> {{'BEFORE_ACTIVATION_LOGOUT' | translate}}
</div>
<div class="form-group">
<button ng-click="logout()" type="submit" class="btn btn-danger">{{'LOGOUT' | translate}}</button>
</div>
</div>
</div>
</div>
</div>
......
......@@ -22,10 +22,11 @@
function ($scope, $route, $routeParams, $filter, $location, $timeout, managerDatastoreUser,
browserClient, helper) {
$scope.is_logged_in = managerDatastoreUser.is_logged_in();
$scope.select_server = select_server;
$scope.changing = changing;
$scope.activate_code = activate_code;
$scope.logout = logout;
activate();
......@@ -59,6 +60,12 @@
browserClient.get_base_url().then(function(base_url){
$scope.base_url = base_url;
});
browserClient.on("logout", function () {
$timeout(function () {
$scope.is_logged_in = managerDatastoreUser.is_logged_in();
});
});
}
/**
......@@ -113,6 +120,12 @@
*/
function activate_code (activation_code) {
var is_logged_in = managerDatastoreUser.is_logged_in();
if (is_logged_in) {
return;
}
function onError() {
alert("Error, should not happen.");
}
......@@ -144,9 +157,22 @@
}
}
/**
* @ngdoc
* @name psonocli.controller:ActivationCtrl#logout
* @methodOf psonocli.controller:ActivationCtrl
*
* @description
* Triggered either automatically or by pressing the activate button
*/
function logout() {
managerDatastoreUser.logout();
}
/* preselected values */
$scope.$on('$routeChangeSuccess', function () {
$scope.activationFormKey = $routeParams['activation_code'];
if ($routeParams.hasOwnProperty('activation_code') && $routeParams['activation_code'].length > 0) {
$timeout(function(){
activate_code($routeParams['activation_code']);
......
......@@ -434,6 +434,7 @@
* @returns {promise} Returns a promise with the logout status
*/
var logout = function (token, session_secret_key, session_id) {
var endpoint = '/authentication/logout/';
var connection_type = "POST";
var data = {
......
......@@ -914,7 +914,61 @@
/**
* @ngdoc
* @name psonocli.managerDatastorePassword#get_all_child_shares
* @name psonocli.managerDatastorePassword#get_all_child_shares_by_path
* @methodOf psonocli.managerDatastorePassword
*
* @description
* fills other_children with all child shares of a given path
*
* @param {TreeObject|undefined} obj the object to search
* @param {int|undefined} share_distance hare_distance the distance in shares to search (-1 = unlimited search, 0 stop search)
* @param {Array} other_children The list of found children that will be updated with new findings
* @param {Array} [path] (optional) The path to prepend, if not provided an empty path will be assumed.
*/
var get_all_child_shares = function(obj, share_distance, other_children, path) {
if (typeof(path) === 'undefined') {
path = []
}
var n, l, new_path;
if (share_distance === 0) {
return
}
//search in folders
if (obj.hasOwnProperty('folders')) {
for (n = 0, l = obj.folders.length; n < l; n++) {
new_path = path.slice();
new_path.push(obj.folders[n].id);
if (typeof(obj.folders[n].share_id) !== 'undefined') {
other_children.push({
share: obj.folders[n],
path: new_path
});
get_all_child_shares(obj.folders[n], share_distance-1, other_children, new_path);
} else {
get_all_child_shares(obj.folders[n], share_distance, other_children, new_path);
}
}
}
// search in items
if (obj.hasOwnProperty('items')) {
for (n = 0, l = obj.items.length; n < l; n++) {
new_path = path.slice();
new_path.push(obj.items[n].id);
if (typeof(obj.items[n].share_id) !== 'undefined') {
other_children.push({
share: obj.items[n],
path: new_path
});
}
}
}
};
/**
* @ngdoc
* @name psonocli.managerDatastorePassword#get_all_child_shares_by_path
* @methodOf psonocli.managerDatastorePassword
*
* @description
......@@ -922,13 +976,12 @@
*
* @param {Array} path The path to search for child shares
* @param {TreeObject|undefined} [datastore] (optional) if obj provided
* @param {Array} other_children The list of found children
* @param {Array} other_children The list of found children that will be updated with new findings
* @param {int|undefined} [share_distance] (optional) share_distance the distance in shares to search (-1 = unlimited search, 0 stop search)
* @param {TreeObject|undefined} [obj] (optional) if not provided we will search it in the datastore according to the provided path first
*/
var get_all_child_shares = function(path, datastore, other_children, share_distance, obj) {
var get_all_child_shares_by_path = function(path, datastore, other_children, share_distance, obj) {
var n, l, new_path;
if (share_distance === 0) {
return
}
......@@ -937,40 +990,12 @@
var path_copy = path.slice();
var search = find_in_datastore(path_copy, datastore);
obj = search[0][search[1]];
return get_all_child_shares(path, datastore, other_children, share_distance, obj)
return get_all_child_shares(obj, share_distance, other_children, path)
} else if (obj === false) {
// TODO Handle not found
console.log("HANDLE not found!");
} else {
//search in folders
if (obj.hasOwnProperty('folders')) {
for (n = 0, l = obj.folders.length; n < l; n++) {
new_path = path.slice();
new_path.push(obj.folders[n].id);
if (typeof(obj.folders[n].share_id) !== 'undefined') {
other_children.push({
share: obj.folders[n],
path: new_path
});
get_all_child_shares(new_path, obj, other_children, share_distance-1, obj.folders[n]);
} else {
get_all_child_shares(new_path, obj, other_children, share_distance, obj.folders[n]);
}
}
}
// search in items
if (obj.hasOwnProperty('items')) {
for (n = 0, l = obj.items.length; n < l; n++) {
new_path = path.slice();
new_path.push(obj.items[n].id);
if (typeof(obj.items[n].share_id) !== 'undefined') {
other_children.push({
share: obj.items[n],
path: new_path
});
}
}
}
get_all_child_shares(obj, share_distance, other_children, path)
}
};
......@@ -1664,6 +1689,7 @@
itemBlueprint.register('save_datastore_content', save_datastore_content);
itemBlueprint.register('find_in_datastore', find_in_datastore);
itemBlueprint.register('on_share_added', on_share_added);
managerShare.register('get_all_child_shares', get_all_child_shares);
settings.register('get_password_datastore', get_password_datastore);
return {
......@@ -1675,6 +1701,7 @@
bookmark_active_tab: bookmark_active_tab,
find_in_datastore: find_in_datastore,
search_in_datastore: search_in_datastore,
get_all_child_shares_by_path: get_all_child_shares_by_path,
get_all_child_shares: get_all_child_shares,
get_all_secret_links: get_all_secret_links,
get_all_file_links: get_all_file_links,
......
......@@ -638,12 +638,13 @@
});
}
return apiClient.logout(managerBase.get_token())
return apiClient.logout(managerBase.get_token(), managerBase.get_session_secret_key())
.then(onSuccess, onError);
};
$rootScope.$on('force_logout', function() {
logout();
managerBase.delete_local_data();
browserClient.emit("logout", null);
});
/**
......
......@@ -10,6 +10,7 @@
* @requires psonocli.cryptoLibrary
* @requires psonocli.managerSecretLink
* @requires psonocli.managerFileLink
* @requires psonocli.managerShareLink
* @requires psonocli.itemBlueprint
*
* @description
......@@ -17,7 +18,8 @@
*/
var managerShare = function($q, managerBase, apiClient, cryptoLibrary, managerSecretLink, managerFileLink,
itemBlueprint) {
managerShareLink, itemBlueprint) {
var registrations = {};
/**
* @ngdoc
......@@ -137,6 +139,9 @@
var create_share = function (content, parent_share_id,
parent_datastore_id, link_id) {
var child_shares = [];
registrations['get_all_child_shares'](content, 1, child_shares, []);
var filtered_content = managerBase.filter_datastore_content(content);
var old_link_id;
......@@ -170,6 +175,11 @@
managerFileLink.move_file_links(filtered_content, content.data.share_id);
}
// Update all child shares to be now a child of this share.
for (var i = 0; i < child_shares.length; i++) {
managerShareLink.move_share_link(child_shares[i]['share']['id'], content.data.share_id, undefined)
}
return {share_id: content.data.share_id, secret_key: secret_key};
};
......@@ -496,6 +506,21 @@
return false;
};
/**
* @ngdoc
* @name psonocli.managerShare#register
* @methodOf psonocli.managerShare
*
* @description
* used to register functions to bypass circular dependencies
*
* @param {string} key The key of the function (usually the function name)
* @param {function} func The call back function
*/
var register = function (key, func) {
registrations[key] = func;
};
// registrations
itemBlueprint.register('read_share_rights', read_share_rights);
......@@ -516,12 +541,13 @@
decrypt_share: decrypt_share,
accept_share_right: accept_share_right,
decline_share_right: decline_share_right,
get_closest_parent_share: get_closest_parent_share
get_closest_parent_share: get_closest_parent_share,
register: register
};
};
var app = angular.module('psonocli');
app.factory("managerShare", ['$q', 'managerBase', 'apiClient', 'cryptoLibrary', 'managerSecretLink', 'managerFileLink',
'itemBlueprint', managerShare]);
'managerShareLink', 'itemBlueprint', managerShare]);
}(angular));
\ No newline at end of file
......@@ -646,7 +646,7 @@
path: []
});
} else {
managerDatastorePassword.get_all_child_shares([], datastore, child_shares, 1, element);
managerDatastorePassword.get_all_child_shares_by_path([], datastore, child_shares, 1, element);
}
var secret_links = managerDatastorePassword.get_all_secret_links(element);
var file_links = managerDatastorePassword.get_all_file_links(element);
......@@ -751,7 +751,7 @@
path: []
});
} else {
managerDatastorePassword.get_all_child_shares([], datastore, child_shares, 1, element);
managerDatastorePassword.get_all_child_shares_by_path([], datastore, child_shares, 1, element);
}
var secret_links = managerDatastorePassword.get_all_secret_links(element);
......
......@@ -215,7 +215,7 @@
* @description
* removes all objects in all dbs (excluding the persistent one) or only in the specified one
*
* @param {string} db (optional) The database
* @param {string} [db] (optional) The database
*/
function remove_all(db) {
if (typeof db !== 'undefined') {
......
{
"REGISTRATION_SUCCESSFUL": "Successfully registered.",
"REGISTRATION_HAS_BEEN_DISABLED": "Registrierung ist abgeschalten.",
"REGISTRATION_FAILED_USERNAME_ALREADY_EXISTS": "Registrierungsfehler. Der Benutzername existiert bereits.",
"REGISTRATION_FAILED_USERNAME_AND_EMAIL_HAVE_TO_MATCH": "Registrierungsfehler. Der Benutzername und die E-Mail müssen gleich sein.",
"REGISTRATION_EMAIL_DELIVERY_FAILED": "Registrierungs E-Mail Versand fehlgeschlagen. Benutzeraccount nicht erstellt.",
"BEFORE_ACTIVATION_LOGOUT": "Sie sind derzeit eingeloggt. Bevor sie einen anderen Account aktivieren sollten sie sich abmelden.",
"USER_SELECTION": "Benutzerauswahl",
"ADD_RIGHT": "Recht hinzufügen",
"INFO_NO_READ_RIGHTS_FOR_FILE_REPOSITORY_RIGHT": "Sie haben nicht die nötigen Berechtigungen um die Konfiguration des Datenrepositories einsehen zu können.",
......@@ -119,7 +125,7 @@
"ADD_NEW_KEY": "Neuen Schlüssel hinzufügen",
"EXISTING_KEYS": "Existierende Schlüssel",
"PASSWORD_CHANGE_LOGOUT_OTHER_DEVICES": "Sie haben ihr Passwort geändert. Wir empfehlen ihnen ihre andere Geräte abzumelden!",
"LOGOUT_OTHER_DEVICES": "Andere Geräte ausloggen",
"LOGOUT_OTHER_DEVICES": "Andere Geräte abmelden",
"IT_IS_IMPOSSIBLE_TO_REVERT_DELETE_DATASTORE": "Diese Aktion ist unumkehrbar. Die Löschung eines Datastores ist Permanent. Jeglicher Inhalt des Datenspeichers geht dabei verloren!",
"YOUR_PASSWORD_IS_REQUIRED": "Dein Passwort ist erforderlich",
"DELETE_DATASTORE": "Datenspeicher Löschen",
......
{
"REGISTRATION_SUCCESSFUL": "Successfully registered.",
"REGISTRATION_HAS_BEEN_DISABLED": "Registration has been disabled.",
"REGISTRATION_FAILED_USERNAME_ALREADY_EXISTS": "Registration failed. Username already exists.",
"REGISTRATION_FAILED_USERNAME_AND_EMAIL_HAVE_TO_MATCH": "Registration failed. Username and email have to match.",
"REGISTRATION_EMAIL_DELIVERY_FAILED": "Registration E-Mail delivery failed. Account not created.",
"BEFORE_ACTIVATION_LOGOUT": "You are currently logged in. Before activating another account please logout.",
"USER_SELECTION": "User selection",
"ADD_RIGHT": "Add right",
"INFO_NO_READ_RIGHTS_FOR_FILE_REPOSITORY_RIGHT": "You do not have the necessary permissions to view the configuration of this data repository.",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment