-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to protect shares by link with a password
- Loading branch information
Showing
21 changed files
with
1,392 additions
and
913 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
(function (w, d) { | ||
if (!w.fetch || !w.Headers) return | ||
|
||
const form = d.getElementById('share-by-link-password-form') | ||
const field = d.getElementById('password-field') | ||
const submit = d.getElementById('password-submit') | ||
const input = d.getElementById('password') | ||
const permID = d.getElementById('perm-id') | ||
|
||
const onSubmit = function (event) { | ||
event.preventDefault() | ||
input.setAttribute('disabled', true) | ||
submit.setAttribute('disabled', true) | ||
|
||
const data = new URLSearchParams() | ||
data.append('password', input.value) | ||
data.append('perm_id', permID.value) | ||
|
||
const headers = new Headers() | ||
headers.append('Content-Type', 'application/x-www-form-urlencoded') | ||
|
||
return fetch(form.action, { | ||
method: 'POST', | ||
headers: headers, | ||
body: data, | ||
credentials: 'include', | ||
}) | ||
.then((response) => { | ||
if (response.status < 400) { | ||
const tooltip = field.querySelector('.invalid-tooltip') | ||
if (tooltip) { | ||
tooltip.classList.add('d-none') | ||
} | ||
submit.innerHTML = '<span class="icon icon-check"></span>' | ||
submit.classList.add('btn-done') | ||
w.location.reload() | ||
} else { | ||
return response.json().then(function (body) { | ||
w.showError(field, body.error) | ||
input.removeAttribute('disabled') | ||
submit.removeAttribute('disabled') | ||
}) | ||
} | ||
}) | ||
.catch((err) => w.showError(field, err)) | ||
} | ||
|
||
form.addEventListener('submit', onSubmit) | ||
})(window, document) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!DOCTYPE html> | ||
<html lang="{{.Locale}}"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="refresh" content="3600"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta name="theme-color" content="#fff"> | ||
<title>{{.Title}}</title> | ||
<link rel="stylesheet" href="{{asset .Domain "/fonts/fonts.css" .ContextName}}"> | ||
<link rel="stylesheet" href="{{asset .Domain "/css/cozy-bs.min.css" .ContextName}}"> | ||
<link rel="stylesheet" href="{{asset .Domain "/styles/theme.css" .ContextName}}"> | ||
<link rel="stylesheet" href="{{asset .Domain "/styles/cirrus.css" .ContextName}}"> | ||
{{.Favicon}} | ||
</head> | ||
<body class="cirrus theme-inverted"> | ||
<form id="share-by-link-password-form" method="POST" action="{{.Action}}" class="d-contents"> | ||
<main class="wrapper"> | ||
|
||
<header class="wrapper-top"> | ||
<a href="https://cozy.io/" class="btn p-2 d-sm-none"> | ||
<img src="{{asset .Domain "/images/logo-dark.svg"}}" alt="Cozy Cloud" class="logo" /> | ||
</a> | ||
</header> | ||
|
||
<div class="d-flex flex-column align-items-center"> | ||
<img src="{{asset .Domain "/images/security.svg"}}" alt="" class="illustration mb-3" /> | ||
<h1 class="h4 h2-md mb-3 text-center">{{t "Share by link Password Title"}}</h1> | ||
|
||
<div id="password-field" class="input-group form-floating has-validation w-100"> | ||
<input id="perm-id" type="hidden" name="perm_id" value="{{.PermID}}" /> | ||
<input type="password" class="form-control form-control-md-lg" id="password" name="passphrase" autofocus spellcheck="false" /> | ||
<label for="password">{{t "Share by link Password Field"}}</label> | ||
<button id="password-visibility-button" class="btn btn-outline-info" | ||
type="button" | ||
name="password-visibility" | ||
data-show="{{t "Login Password show"}}" | ||
data-hide="{{t "Login Password hide"}}" | ||
title="{{t "Login Password show"}}"> | ||
<span id="password-visibility-icon" class="icon icon-eye-closed"></span> | ||
</button> | ||
</div> | ||
</div> | ||
|
||
<footer class="w-100"> | ||
<button id="password-submit" class="btn btn-primary btn-md-lg w-100 my-3 mt-md-5" type="submit"> | ||
{{t "Share by link Password Submit"}} | ||
</button> | ||
</footer> | ||
|
||
</main> | ||
</form> | ||
<script src="{{asset .Domain "/scripts/cirrus.js"}}"></script> | ||
<script src="{{asset .Domain "/scripts/share-by-link.js"}}"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.