admin: allow certid to finish by .p12, to permit downloading .p12 file

This commit is contained in:
nemunaire 2019-02-05 01:45:19 +01:00
parent 703eaef880
commit b778d29dd9
3 changed files with 4 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import (
"log"
"net/http"
"strconv"
"strings"
"time"
"srs.epita.fr/fic-server/libfic"
@ -317,7 +318,7 @@ func fileHandler(f func(fic.EFile, []byte) (interface{}, error)) func(httprouter
func certificateHandler(f func(fic.Certificate, []byte) (interface{}, error)) func(httprouter.Params, []byte) (interface{}, error) {
return func(ps httprouter.Params, body []byte) (interface{}, error) {
if certid, err := strconv.ParseUint(string(ps.ByName("certid")), 10, 64); err != nil {
if certid, err := strconv.ParseUint(strings.TrimSuffix(string(ps.ByName("certid")), ".p12"), 10, 64); err != nil {
return nil, err
} else if cert, err := fic.GetCertificate(certid); err != nil {
return nil, err

View File

@ -28,7 +28,7 @@
</td>
<td>{{ certificate.revoked }}</td>
<td>
<a type="button" class="btn btn-sm btn-success" href="api/certs/{{ certificate.id }}" target="_self">Télécharger</a>
<a type="button" class="btn btn-sm btn-success" href="api/certs/{{ certificate.id }}.p12" target="_self">Télécharger</a>
<button type="button" class="btn btn-sm btn-danger" data-toggle="modal" data-target="#revokeModal" data-certificate="{{ certificate.id }}" ng-class="{disabled: certificate.revoked}">Révoquer</button>
</td>
</tr>

View File

@ -89,7 +89,7 @@
</dd>
<dt>
Date de création
<a class="btn btn-sm btn-success float-right" href="api/certs/{{ cert.id }}">Télécharger</a>
<a class="btn btn-sm btn-success float-right" href="api/certs/{{ cert.id }}.p12" target="_self">Télécharger</a>
</dt>
<dd>{{ cert.creation }}</dd>
<dt>Mot de passe</dt>