summaryrefslogtreecommitdiffstats
path: root/models/login_source.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-03-01 21:08:10 +0000
committerGitHub <noreply@github.com>2021-03-01 22:08:10 +0100
commitf0e15250b9e322cc7731ba026d12387c2b549a42 (patch)
treef13d46119077ba924d620ef172b91daa315bda0a /models/login_source.go
parent59fd641d1fb021e35aea7f9f4a1916cc11ef5c51 (diff)
downloadgitea-f0e15250b9e322cc7731ba026d12387c2b549a42.tar.gz
gitea-f0e15250b9e322cc7731ba026d12387c2b549a42.zip
Migrate to use jsoniter instead of encoding/json (#14841)
* Migrate to use jsoniter * fix tests * update gitea.com/go-chi/binding Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'models/login_source.go')
-rw-r--r--models/login_source.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/models/login_source.go b/models/login_source.go
index d351f12861..37bbdc4597 100644
--- a/models/login_source.go
+++ b/models/login_source.go
@@ -7,7 +7,6 @@ package models
import (
"crypto/tls"
- "encoding/json"
"errors"
"fmt"
"net/smtp"
@@ -22,6 +21,7 @@ import (
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"
+ jsoniter "github.com/json-iterator/go"
"xorm.io/xorm"
"xorm.io/xorm/convert"
@@ -75,11 +75,13 @@ type LDAPConfig struct {
// FromDB fills up a LDAPConfig from serialized format.
func (cfg *LDAPConfig) FromDB(bs []byte) error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Unmarshal(bs, &cfg)
}
// ToDB exports a LDAPConfig to a serialized format.
func (cfg *LDAPConfig) ToDB() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Marshal(cfg)
}
@@ -101,11 +103,13 @@ type SMTPConfig struct {
// FromDB fills up an SMTPConfig from serialized format.
func (cfg *SMTPConfig) FromDB(bs []byte) error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Unmarshal(bs, cfg)
}
// ToDB exports an SMTPConfig to a serialized format.
func (cfg *SMTPConfig) ToDB() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Marshal(cfg)
}
@@ -116,11 +120,13 @@ type PAMConfig struct {
// FromDB fills up a PAMConfig from serialized format.
func (cfg *PAMConfig) FromDB(bs []byte) error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Unmarshal(bs, &cfg)
}
// ToDB exports a PAMConfig to a serialized format.
func (cfg *PAMConfig) ToDB() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Marshal(cfg)
}
@@ -136,11 +142,13 @@ type OAuth2Config struct {
// FromDB fills up an OAuth2Config from serialized format.
func (cfg *OAuth2Config) FromDB(bs []byte) error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Unmarshal(bs, cfg)
}
// ToDB exports an SMTPConfig to a serialized format.
func (cfg *OAuth2Config) ToDB() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Marshal(cfg)
}
@@ -155,11 +163,13 @@ type SSPIConfig struct {
// FromDB fills up an SSPIConfig from serialized format.
func (cfg *SSPIConfig) FromDB(bs []byte) error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Unmarshal(bs, cfg)
}
// ToDB exports an SSPIConfig to a serialized format.
func (cfg *SSPIConfig) ToDB() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Marshal(cfg)
}