Add AuthInfoResp.authInfo

This commit is contained in:
emersion 2017-08-22 09:21:50 +02:00
parent dac767c4bf
commit 24aec2c52a
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
1 changed files with 21 additions and 18 deletions

View File

@ -13,16 +13,6 @@ type authInfoReq struct {
Username string Username string
} }
type AuthInfoResp struct {
resp
Version int
TwoFactor int
Modulus string
ServerEphemeral string
Salt string
SRPSession string
}
type AuthInfo struct { type AuthInfo struct {
TwoFactor int TwoFactor int
version int version int
@ -32,6 +22,26 @@ type AuthInfo struct {
srpSession string srpSession string
} }
type AuthInfoResp struct {
resp
AuthInfo
Version int
Modulus string
ServerEphemeral string
Salt string
SRPSession string
}
func (resp *AuthInfoResp) authInfo() *AuthInfo {
info := &resp.AuthInfo
info.version = resp.Version
info.modulus = resp.Modulus
info.serverEphemeral = resp.ServerEphemeral
info.salt = resp.Salt
info.srpSession = resp.SRPSession
return info
}
func (c *Client) AuthInfo(username string) (*AuthInfo, error) { func (c *Client) AuthInfo(username string) (*AuthInfo, error) {
reqData := &authInfoReq{ reqData := &authInfoReq{
ClientID: c.ClientID, ClientID: c.ClientID,
@ -49,14 +59,7 @@ func (c *Client) AuthInfo(username string) (*AuthInfo, error) {
return nil, err return nil, err
} }
return &AuthInfo{ return respData.authInfo(), nil
TwoFactor: respData.TwoFactor,
version: respData.Version,
modulus: respData.Modulus,
serverEphemeral: respData.ServerEphemeral,
salt: respData.Salt,
srpSession: respData.SRPSession,
}, nil
} }
type authReq struct { type authReq struct {