Checks username and password against the wiki.
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
package wikiauth
import ( "github.com/sadbox/mediawiki" )
// WikiAuth is the structure responsible for wiki authentication. It's immuitable
// and thread safe. The only time it connects is to log in.
type WikiAuth struct { url string }
// New creates a new wiki authenticator instance.
func New(url string) *WikiAuth { return &WikiAuth{url} }
// Login connects to the wiki and logs in. It will not reuse clients between
// logins, so it's thus threadsafe.
func (wikiAuth *WikiAuth) Login(username, password string) error { client, err := mediawiki.New(wikiAuth.url, "") if err != nil { return err }
err = client.Login(username, password) if err != nil { return err }
client.Logout()
return nil }
|