From 24aec2c52af9b0ea2dcd5c0ca51d5c5536ea65dc Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 22 Aug 2017 09:21:50 +0200 Subject: [PATCH] Add AuthInfoResp.authInfo --- protonmail/auth.go | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/protonmail/auth.go b/protonmail/auth.go index c425158..da806b2 100644 --- a/protonmail/auth.go +++ b/protonmail/auth.go @@ -13,16 +13,6 @@ type authInfoReq struct { Username string } -type AuthInfoResp struct { - resp - Version int - TwoFactor int - Modulus string - ServerEphemeral string - Salt string - SRPSession string -} - type AuthInfo struct { TwoFactor int version int @@ -32,6 +22,26 @@ type AuthInfo struct { 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) { reqData := &authInfoReq{ ClientID: c.ClientID, @@ -49,14 +59,7 @@ func (c *Client) AuthInfo(username string) (*AuthInfo, error) { return nil, err } - return &AuthInfo{ - TwoFactor: respData.TwoFactor, - version: respData.Version, - modulus: respData.Modulus, - serverEphemeral: respData.ServerEphemeral, - salt: respData.Salt, - srpSession: respData.SRPSession, - }, nil + return respData.authInfo(), nil } type authReq struct {