X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=auth.go;h=de355f1ed8365af80cc5457b76c1d2a5a3f1f4fc;hb=e281b2b16d026a5068596ad8c657659fadb32b74;hp=1b3fe234df882466029b32deeb3388dca42695aa;hpb=59218ebf4cf9c2353dfa2cb416ee7d2542a3b9b9;p=go-anidb.git diff --git a/auth.go b/auth.go index 1b3fe23..de355f1 100644 --- a/auth.go +++ b/auth.go @@ -83,11 +83,6 @@ func newCredentials(username, password, udpKey string) *credentials { } } -// Re-authenticates the current user. Do not use unless really necessary. -func (a *AniDB) ReAuth() error { - return a.udp.ReAuth() -} - func (udp *udpWrap) ReAuth() error { if c := udp.credentials; c != nil { defer runtime.GC() // any better way to clean the plaintexts? @@ -104,32 +99,32 @@ func (udp *udpWrap) ReAuth() error { // Saves the used credentials in the AniDB struct, to allow automatic // re-authentication when needed; they are (properly) encrypted with a key that's // uniquely generated every time the module is initialized. -func (a *AniDB) SetCredentials(username, password, udpKey string) { - a.udp.credentials.shred() - a.udp.credentials = newCredentials(username, password, udpKey) +func (adb *AniDB) SetCredentials(username, password, udpKey string) { + adb.udp.credentials.shred() + adb.udp.credentials = newCredentials(username, password, udpKey) } // Authenticates to anidb's UDP API and, on success, stores the credentials using // SetCredentials. If udpKey is not "", the communication with the server // will be encrypted, but in the VERY weak ECB mode. -func (a *AniDB) Auth(username, password, udpKey string) (err error) { +func (adb *AniDB) Auth(username, password, udpKey string) (err error) { defer runtime.GC() // any better way to clean the plaintexts? - if err = a.udp.Auth(username, password, udpKey); err == nil { - a.udp.connected = true - a.SetCredentials(username, password, udpKey) + if err = adb.udp.Auth(username, password, udpKey); err == nil { + adb.udp.connected = true + adb.SetCredentials(username, password, udpKey) } return } // Logs the user out and removes the credentials from the AniDB struct. -func (a *AniDB) Logout() error { - if a.udp.connected { - a.udp.credentials.shred() - a.udp.credentials = nil +func (adb *AniDB) Logout() error { + if adb.udp.connected { + adb.udp.credentials.shred() + adb.udp.credentials = nil - a.udp.connected = false - return a.udp.Logout() + adb.udp.connected = false + return adb.udp.Logout() } return nil }