Skip to content

DOI: New request data #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 16, 2019
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
21 changes: 16 additions & 5 deletions routes/doi.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package routes

import (
"encoding/json"
"net/http"
"net/url"

Expand All @@ -17,9 +18,21 @@ func RequestDOI(c *context.Context) {
return
}

repo := c.Repo.Repository.FullName()
username := c.User.Name
verification, err := libgin.EncryptURLString([]byte(setting.DOI.Key), repo+username)
realname := c.User.FullName
repo := c.Repo.Repository.FullName()
email := c.User.Email

data := libgin.DOIRequestData{
Username: username,
Realname: realname,
Repository: repo,
Email: email,
}

log.Trace("Encrypting data for DOI: %+v", data)
dataj, _ := json.Marshal(data)
regrequest, err := libgin.EncryptURLString([]byte(setting.DOI.Key), string(dataj))
if err != nil {
log.Error(2, "Could not encrypt secret key: %s", err)
c.Status(http.StatusInternalServerError)
Expand All @@ -31,9 +44,7 @@ func RequestDOI(c *context.Context) {
}

params := url.Values{}
params.Add("repo", repo)
params.Add("user", username)
params.Add("verification", verification)
params.Add("regrequest", regrequest)
doiurl.RawQuery = params.Encode()
target, _ := url.PathUnescape(doiurl.String())
log.Trace(target)
Expand Down
9 changes: 9 additions & 0 deletions vendor/github.com/G-Node/libgin/libgin/doi.go

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