mirror of
https://github.com/documize/community.git
synced 2025-07-22 14:49:42 +02:00
wip
This commit is contained in:
parent
0b51608383
commit
9d1af37f6e
22 changed files with 2215 additions and 647 deletions
|
@ -176,3 +176,60 @@ type licenseJSON struct {
|
|||
<Signature>some signature</Signature>
|
||||
</DocumizeLicense>
|
||||
*/
|
||||
|
||||
// SaveAuthConfig returns installation-wide authentication configuration
|
||||
func SaveAuthConfig(w http.ResponseWriter, r *http.Request) {
|
||||
method := "SaveAuthConfig"
|
||||
p := request.GetPersister(r)
|
||||
|
||||
if !p.Context.Global {
|
||||
writeForbiddenError(w)
|
||||
return
|
||||
}
|
||||
|
||||
defer r.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
writePayloadError(w, method, err)
|
||||
return
|
||||
}
|
||||
|
||||
var data authData
|
||||
err = json.Unmarshal(body, &data)
|
||||
if err != nil {
|
||||
writePayloadError(w, method, err)
|
||||
return
|
||||
}
|
||||
|
||||
org, err := p.GetOrganization(p.Context.OrgID)
|
||||
if err != nil {
|
||||
util.WriteGeneralSQLError(w, method, err)
|
||||
return
|
||||
}
|
||||
|
||||
org.AuthProvider = data.AuthProvider
|
||||
org.AuthConfig = data.AuthConfig
|
||||
|
||||
p.Context.Transaction, err = request.Db.Beginx()
|
||||
if err != nil {
|
||||
writeTransactionError(w, method, err)
|
||||
return
|
||||
}
|
||||
|
||||
err = p.UpdateAuthConfig(org)
|
||||
if err != nil {
|
||||
util.WriteGeneralSQLError(w, method, err)
|
||||
p.Context.Transaction.Rollback()
|
||||
return
|
||||
}
|
||||
|
||||
p.Context.Transaction.Commit()
|
||||
|
||||
util.WriteSuccessEmptyJSON(w)
|
||||
}
|
||||
|
||||
type authData struct {
|
||||
AuthProvider string `json:"authProvider"`
|
||||
AuthConfig string `json:"authConfig"`
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue