mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-02 23:26:23 -07:00
Implemented GetStaffName & GetStaffBySession
This commit is contained in:
parent
bae28256e0
commit
5b2e6800a1
1 changed files with 22 additions and 11 deletions
|
@ -80,23 +80,34 @@ func GetReplyFileCount(postID int) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStaffName returns the name associated with a session
|
// GetStaffName returns the name associated with a session
|
||||||
func GetStaffName(session string) (name string, err error) {
|
func GetStaffName(session string) (string, error) {
|
||||||
//after refactor, check if still used
|
const sql = `SELECT staff.username from DBPREFIXstaff as staff
|
||||||
return "DUMMY", errors.New("Not implemented")
|
JOIN DBPREFIXsessions as sessions
|
||||||
|
ON sessions.staff_id = staff.id
|
||||||
|
WHERE sessions.data = ?`
|
||||||
|
var username string
|
||||||
|
err := QueryRowSQL(sql, InterfaceSlice(session), InterfaceSlice(&username))
|
||||||
|
return username, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStaffBySession gets the staff that is logged in in the given session
|
// GetStaffBySession gets the staff that is logged in in the given session
|
||||||
// Deprecated: This method was created to support old functionality during the database refactor of april 2020
|
// Deprecated: This method was created to support old functionality during the database refactor of april 2020
|
||||||
// The code should be changed to reflect the new database design
|
// The code should be changed to reflect the new database design
|
||||||
func GetStaffBySession(session string) (*Staff, error) { //TODO not upt to date with old db yet
|
func GetStaffBySession(session string) (*Staff, error) { //TODO not upt to date with old db yet
|
||||||
// staff := new(Staff)
|
const sql = `SELECT
|
||||||
// err := queryRowSQL("SELECT * FROM DBPREFIXstaff WHERE username = ?",
|
staff.id,
|
||||||
// []interface{}{name},
|
staff.username,
|
||||||
// []interface{}{&staff.ID, &staff.Username, &staff.PasswordChecksum, &staff.Rank, &staff.Boards, &staff.AddedOn, &staff.LastActive},
|
staff.password_checksum,
|
||||||
// )
|
staff.global_rank,
|
||||||
// return staff, err
|
staff.added_on,
|
||||||
|
staff.last_login
|
||||||
return nil, errors.New("Not implemented")
|
FROM DBPREFIXstaff as staff
|
||||||
|
JOIN DBPREFIXsessions as sessions
|
||||||
|
ON sessions.staff_id = staff.id
|
||||||
|
WHERE sessions.data = ?`
|
||||||
|
staff := new(Staff)
|
||||||
|
err := QueryRowSQL(sql, InterfaceSlice(session), InterfaceSlice(&staff.ID, &staff.Username, &staff.PasswordChecksum, &staff.Rank, &staff.AddedOn, &staff.LastActive))
|
||||||
|
return staff, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStaffByName gets the staff with a given name
|
// GetStaffByName gets the staff with a given name
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue