mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 12:39:17 +00:00
41 lines
954 B
Go
41 lines
954 B
Go
|
package databag
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
func GetProfileMessage(w http.ResponseWriter, r *http.Request) {
|
||
|
|
||
|
account, res := BearerAppToken(r, true);
|
||
|
if res != nil {
|
||
|
ErrResponse(w, http.StatusUnauthorized, res)
|
||
|
return
|
||
|
}
|
||
|
if account.Disabled {
|
||
|
ErrResponse(w, http.StatusGone, res)
|
||
|
return
|
||
|
}
|
||
|
detail := account.AccountDetail
|
||
|
|
||
|
// generate identity DataMessage
|
||
|
identity := Identity{
|
||
|
Revision: account.ProfileRevision,
|
||
|
Handle: account.Username,
|
||
|
Name: detail.Name,
|
||
|
Description: detail.Description,
|
||
|
Location: detail.Location,
|
||
|
Image: detail.Image,
|
||
|
Version: APP_VERSION,
|
||
|
Node: "https://" + getStrConfigValue(CONFIG_DOMAIN, "") + "/",
|
||
|
}
|
||
|
msg, res := WriteDataMessage(detail.PrivateKey, detail.PublicKey, detail.KeyType,
|
||
|
APP_SIGNPKCS1V15, account.Guid, APP_MSGIDENTITY, &identity)
|
||
|
if res != nil {
|
||
|
ErrResponse(w, http.StatusInternalServerError, res)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
WriteResponse(w, msg)
|
||
|
}
|
||
|
|