Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions js/terms_of_service-admin.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/terms_of_service-admin.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/terms_of_service-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/terms_of_service-public.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/terms_of_service-registration.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/terms_of_service-registration.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/terms_of_service-user.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/terms_of_service-user.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,39 @@ public function registerFrontend(IRequest $request, IConfig $config, IUserSessio
Util::addScript('terms_of_service', 'terms_of_service-public');
}
}

// Skip login-related pages
// TODO: Add a universal way to specify skipped pages instead of hardcoding
$skipPatterns = [
// Login
'#^/login$#',
// Login Flow Grant must have the terms of service
// so that the user can accept them before using the app
// TODO: add a checkbox on the login instead, like on the Registration app
'#^/login/(?!flow/grant|v2/grant)#',
// SAML
'#^/apps/user_saml/saml$#',
'#^/apps/user_saml/saml/#',
// user_oidc
'#^/apps/user_oidc/code$#',
'#^/apps/user_oidc/sls$#',
'#^/apps/user_oidc/id4me$#',
'#^/apps/user_oidc/id4me/code$#',
// registration
'#^/apps/registration(?:$|/)#',
];
if (array_filter($skipPatterns, fn($pattern) => preg_match($pattern, $request->getPathInfo()))) {
return;
}

if ($userSession->getUser() instanceof IUser) {
// Logged-in user
Util::addScript('terms_of_service', 'terms_of_service-user');
} else if ($config->getAppValue(self::APPNAME, 'tos_on_public_shares', '0') === '1') {
// Guests on public pages
Util::addScript('terms_of_service', 'terms_of_service-public');
}

}

public function addStorageWrapper(): void {
Expand Down
166 changes: 97 additions & 69 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"stylelint:fix": "stylelint **/*.css **/*.scss **/*.vue --fix"
},
"dependencies": {
"@nextcloud/auth": "^2.4.0",
"@nextcloud/axios": "^2.3.0",
"@nextcloud/dialogs": "^4.2.0",
"@nextcloud/router": "^2.1.1",
Expand Down
5 changes: 3 additions & 2 deletions src/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@
*/

import Vue from 'vue'
import { getCurrentUser } from '@nextcloud/auth'
import UserApp from './UserApp.vue'

Vue.prototype.t = t
Vue.prototype.n = n
Vue.prototype.OC = OC
Vue.prototype.OCA = OCA

const hasToken = (document.getElementById('sharingToken') !== null)
const isNotLoggedIn = getCurrentUser() === null
const isPasswordProtected = (document.getElementById('password-submit') !== null)

if (hasToken && !isPasswordProtected) {
if (isNotLoggedIn && !isPasswordProtected) {
const tofc = document.createElement('div')
tofc.id = 'terms_of_service_confirm'
document.body.insertAdjacentElement('afterbegin', tofc)
Expand Down
Loading