web client: don't show the link for expired shares
This commit is contained in:
parent
3f3591bae0
commit
dc19921b0c
5 changed files with 38 additions and 14 deletions
|
@ -220,6 +220,7 @@ func (a *Admin) validate() error {
|
|||
if a.Email != "" && !emailRegex.MatchString(a.Email) {
|
||||
return util.NewValidationError(fmt.Sprintf("email %#v is not valid", a.Email))
|
||||
}
|
||||
a.Filters.AllowList = util.RemoveDuplicates(a.Filters.AllowList)
|
||||
for _, IPMask := range a.Filters.AllowList {
|
||||
_, _, err := net.ParseCIDR(IPMask)
|
||||
if err != nil {
|
||||
|
|
|
@ -67,6 +67,14 @@ func (s *Share) GetScopeAsString() string {
|
|||
}
|
||||
}
|
||||
|
||||
// IsExpired returns true if the share is expired
|
||||
func (s *Share) IsExpired() bool {
|
||||
if s.ExpiresAt > 0 {
|
||||
return s.ExpiresAt < util.GetTimeAsMsSinceEpoch(time.Now())
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// GetInfoString returns share's info as string.
|
||||
func (s *Share) GetInfoString() string {
|
||||
var result strings.Builder
|
||||
|
@ -220,6 +228,7 @@ func (s *Share) validate() error {
|
|||
if err := s.hashPassword(); err != nil {
|
||||
return err
|
||||
}
|
||||
s.AllowFrom = util.RemoveDuplicates(s.AllowFrom)
|
||||
for _, IPMask := range s.AllowFrom {
|
||||
_, _, err := net.ParseCIDR(IPMask)
|
||||
if err != nil {
|
||||
|
|
|
@ -80,8 +80,8 @@
|
|||
<div class="form-group row">
|
||||
<label for="idAllowedIP" class="col-sm-2 col-form-label">Allowed IP/Mask</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" id="idAllowedIP" name="allowed_ip" placeholder=""
|
||||
value="{{.Admin.GetAllowedIPAsString}}" maxlength="255" aria-describedby="allowedIPHelpBlock">
|
||||
<textarea class="form-control" id="idAllowedIP" name="allowed_ip" rows="3" placeholder=""
|
||||
aria-describedby="allowedIPHelpBlock">{{.Admin.GetAllowedIPAsString}}</textarea>
|
||||
<small id="allowedIPHelpBlock" class="form-text text-muted">
|
||||
Comma separated IP/Mask in CIDR format, for example "192.168.1.0/24,10.8.0.100/32"
|
||||
</small>
|
||||
|
|
|
@ -118,8 +118,8 @@
|
|||
<div class="form-group row">
|
||||
<label for="idAllowedIP" class="col-sm-2 col-form-label">Allowed IP/Mask</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" id="idAllowedIP" name="allowed_ip" placeholder=""
|
||||
value="{{.Share.GetAllowedFromAsString}}" maxlength="255" aria-describedby="allowedIPHelpBlock">
|
||||
<textarea class="form-control" id="idAllowedIP" name="allowed_ip" rows="3" placeholder=""
|
||||
aria-describedby="allowedIPHelpBlock">{{.Share.GetAllowedFromAsString}}</textarea>
|
||||
<small id="allowedIPHelpBlock" class="form-text text-muted">
|
||||
Comma separated IP/Mask in CIDR format, for example "192.168.1.0/24,10.8.0.100/32"
|
||||
</small>
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
<th>Name</th>
|
||||
<th>Scope</th>
|
||||
<th>Info</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -41,6 +42,7 @@
|
|||
<td>{{.Name}}</td>
|
||||
<td>{{.GetScopeAsString}}</td>
|
||||
<td>{{.GetInfoString}}</td>
|
||||
<td>{{if .IsExpired}}1{{else}}0{{end}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
|
@ -97,6 +99,9 @@
|
|||
<p>For example:</p>
|
||||
<p><code>curl -F filenames=@file1.txt -F filenames=@file2.txt "share link"</code></p>
|
||||
</div>
|
||||
<div id="expiredShare">
|
||||
This share is no longer accessible because it has expired
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary" type="button" data-dismiss="modal">
|
||||
|
@ -195,17 +200,26 @@
|
|||
var shareData = dt.row({ selected: true }).data();
|
||||
var shareID = shareData[0];
|
||||
var shareScope = shareData[2];
|
||||
var shareURL = '{{.BasePublicSharesURL}}' + "/" + fixedEncodeURIComponent(shareID);
|
||||
if (shareScope == 'Read'){
|
||||
var isExpired = shareData[4];
|
||||
if (isExpired == "1"){
|
||||
$('#expiredShare').show();
|
||||
$('#writeShare').hide();
|
||||
$('#readShare').show();
|
||||
$('#readLink').attr("href", shareURL);
|
||||
$('#readLink').attr("title", shareURL);
|
||||
} else {
|
||||
$('#writeShare').show();
|
||||
$('#readShare').hide();
|
||||
$('#writeLink').attr("href", shareURL);
|
||||
$('#writeLink').attr("title", shareURL);
|
||||
} else {
|
||||
var shareURL = '{{.BasePublicSharesURL}}' + "/" + fixedEncodeURIComponent(shareID);
|
||||
if (shareScope == 'Read'){
|
||||
$('#expiredShare').hide();
|
||||
$('#writeShare').hide();
|
||||
$('#readShare').show();
|
||||
$('#readLink').attr("href", shareURL);
|
||||
$('#readLink').attr("title", shareURL);
|
||||
} else {
|
||||
$('#expiredShare').hide();
|
||||
$('#writeShare').show();
|
||||
$('#readShare').hide();
|
||||
$('#writeLink').attr("href", shareURL);
|
||||
$('#writeLink').attr("title", shareURL);
|
||||
}
|
||||
}
|
||||
$('#linkModal').modal('show');
|
||||
},
|
||||
|
@ -222,7 +236,7 @@
|
|||
"buttons": [],
|
||||
"columnDefs": [
|
||||
{
|
||||
"targets": [0],
|
||||
"targets": [0, 4],
|
||||
"visible": false,
|
||||
"searchable": false
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue