siamauth

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2023 License: MIT Imports: 5 Imported by: 0

README

SIAM UB Auth

https://siam.ub.ac.id authentication with scraping method

import:

import (
	"github.com/dnabil/siamauth"
)

run go get command:

go get github.com/dnabil/siamauth

What's New

Breaking Changes (v0.2.0):

  • Error variables moved to /siamauth/siamerr
  • Login function now returns 2 data, error msg (string) and error

New:

  • feat: GetDataAndLogout, basically: Login() GetData() and Logout()
  • refactor: move scraping logic to a new pkg (/scrape)
  • feat: Scrape addcourse.php logic :D

Usage

siamauth constructor

user := siamauth.NewUser()

After that you can use the methods available for that user :). Documentation

Please note that after logging in, please defer user.Logout() so the session id won't be misused.

Or if you just need the scraping logic for scraping siam pages, import the siamauth/scrape pkg

*I am planning on adding more features like getting schedules, study plan (aka KRS), etc.. but still lazy. Pull requests are welcome :)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type User

type User struct {
	Data        models.UserData
	LoginStatus bool
	// contains filtered or unexported fields
}

func NewUser

func NewUser() *User

constructor

func (*User) GetData

func (s *User) GetData() error

GetData will fill in user's Data or return an error

func (*User) GetDataAndLogout added in v0.2.0

func (s *User) GetDataAndLogout(username, password string) (models.UserData, error)

no need to login first & defer logout.

if you just need to get the data and bounce, use this ;)

func (*User) Login

func (s *User) Login(us string, ps string) (string, error)

Please defer Logout() after this function is called

will return a login error message (from siam) and an error (already logged in/login error/siam ui changes/server down/etc)

func (*User) Logout

func (s *User) Logout() error

Make sure to defer this method after login, so the phpsessionid won't be misused

Directories

Path Synopsis
docs
example command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL