session

package
v0.0.0-...-1b8d80d Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package session provides the material to implement the security layer. A session restrict the operation that are authorized by the session owner, depending on its identity or his role

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrPermission indicates an operation that is not permitted
	ErrPermission = errors.New("Permission denied")
)

Functions

This section is empty.

Types

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session restricts the operation that can be executed by the current user with regards to its role and or relationships

func AnonSession

func AnonSession(store *sqlstore.Store) Session

AnonSession creates a session that is not attached to a particular user

func NewSession

func NewSession(u schema.User, store *sqlstore.Store, conventions feeder.Conventions) Session

NewSession creates a new session

func (*Session) AddJuryToDefenseSession

func (s *Session) AddJuryToDefenseSession(room, id, jury string) error

func (*Session) Convention

func (s *Session) Convention(stu string) (schema.Convention, error)

Convention returns the convention of a given student if the emitter is the student or at least an admin

func (*Session) Conventions

func (s *Session) Conventions() ([]schema.Convention, *feeder.ImportError)

Conventions lists the conventions if the emitter is an admin at minimum

func (*Session) Defense

func (s *Session) Defense(stu string) (schema.Defense, error)

func (*Session) DefenseProgram

func (s *Session) DefenseProgram() ([]schema.DefenseSession, error)

func (*Session) DefenseSession

func (s *Session) DefenseSession(room, id string) (schema.DefenseSession, error)

func (*Session) DefenseSessions

func (s *Session) DefenseSessions() ([]schema.DefenseSession, error)

DefenseSessions returns all the sessions Unfiltered for an admin and more. Otherwise, filter out the sessions I am not a jury member of

func (*Session) DelJuryToDefenseSession

func (s *Session) DelJuryToDefenseSession(room, id, jury string) error

func (*Session) InMyMajor

func (s *Session) InMyMajor(student string) bool

InMyMajor checks if the student is in the major I am the leader of

func (*Session) Internship

func (s *Session) Internship(stu string) (schema.Internship, error)

Internship returns the internship of the emitter or if the emitter is at least a major leader

func (*Session) Internships

func (s *Session) Internships() (schema.Internships, error)

Internships list the internships if the emitter is at least a major leader. Otherwise, all the internships now tutored by the emitter are removed

func (*Session) JuryOf

func (s *Session) JuryOf(student string) bool

JuryOf checks if I am in a jury for a defense. That if indeed I am in the jury, or an admin

func (*Session) Me

func (s *Session) Me() schema.User

Me returns the session emitter

func (*Session) Myself

func (s *Session) Myself(email string) bool

Myself checks if the given email matches the session one

func (*Session) NewDefenseSession

func (s *Session) NewDefenseSession(room string, id string) (schema.DefenseSession, error)

func (*Session) NewInternship

func (s *Session) NewInternship(c schema.Convention) (schema.Internship, []byte, error)

NewInternship validates the convention if the emitter is an admin at minimum

func (*Session) NewStudent

func (s *Session) NewStudent(p schema.Person, major, promotion string, male bool) error

NewStudent creates a new student account if the emitter is an admin at least

func (*Session) NewUser

func (s *Session) NewUser(p schema.Person, role schema.Role) ([]byte, error)

NewUser creates a new user account if the emitter is an admin at least

func (*Session) ReplaceUserWith

func (s *Session) ReplaceUserWith(src, dst string) error

ReplaceUserWith allowed if the emitter is an admin at least

func (*Session) Report

func (s *Session) Report(kind, email string) (schema.ReportHeader, error)

Report returns a report header if the emitter if the student or if he is watching the student

func (*Session) ReportContent

func (s *Session) ReportContent(kind, email string) ([]byte, error)

ReportContent returns the report content if the emitter is the report owner, the tutor or a root. if the report is private, no one else can access the report. Otherwise, the major leader and the admins can access the reports

func (*Session) ResetSurvey

func (s *Session) ResetSurvey(student, kind string) error

ResetSurvey if the emitter is at least an administrator

func (*Session) RmDefense

func (s *Session) RmDefense(student string) error

func (*Session) RmDefenseSession

func (s *Session) RmDefenseSession(room string, id string) error

func (*Session) RmSession

func (s *Session) RmSession(em string) error

RmSession delete the session if the emitter is the session owner or at least an admin

func (*Session) RmUser

func (s *Session) RmUser(email string) error

RmUser removes an account if the emitter is at least an admin and not himself

func (*Session) Role

func (s *Session) Role() schema.Role

Role returns the current user role

func (*Session) SetAlumni

func (s *Session) SetAlumni(student string, a schema.Alumni) error

SetAlumni changes the student next position if the emitter is the targetted student, the tutor, a member of his jury or a major leader at minimum

func (*Session) SetCompany

func (s *Session) SetCompany(stu string, c schema.Company) error

SetCompany changes the company if the emitter is the student or an admin at minimum

func (*Session) SetDefenseGrade

func (s *Session) SetDefenseGrade(stu string, grade int) error

func (*Session) SetEmail

func (s *Session) SetEmail(old, cur string) error

SetEmail change the person email if the emitter is at least an admin

func (*Session) SetMajor

func (s *Session) SetMajor(student string, m string) error

SetMajor changes the student major if the emitter is the student or at least a major leader

func (*Session) SetMale

func (s *Session) SetMale(student string, male bool) error

SetMale changes the student gender if the emitter is the student itself, the tutor or an admin at minimum

func (*Session) SetPromotion

func (s *Session) SetPromotion(student string, p string) error

SetPromotion changes the student promotion if the emitter is the student himself or a major leader at least

func (*Session) SetReportContent

func (s *Session) SetReportContent(kind, email string, cnt []byte) (time.Time, error)

SetReportContent store a report. If the emitter is the current student, it is allowed if the deadline is not passed or if no report has already been uploaded

func (*Session) SetReportDeadline

func (s *Session) SetReportDeadline(kind, email string, t time.Time) error

SetReportDeadline changes the report deadline if the emitter tutors the student or is an admin at minimum

func (*Session) SetReportGrade

func (s *Session) SetReportGrade(kind, email string, g int, comment string) (time.Time, error)

SetReportGrade set the report grade if the emitter is the student tutor or an admin at minimum

func (*Session) SetReportPrivacy

func (s *Session) SetReportPrivacy(kind, email string, p bool) error

SetReportPrivacy changes the report privacy status if the emitter tutors the student or is an admin at minimum

func (*Session) SetStudentDefense

func (s *Session) SetStudentDefense(session, room, student string, t time.Time, public, local bool) error

func (*Session) SetStudentSkippable

func (s *Session) SetStudentSkippable(em string, st bool) error

SetStudentSkippable change the skippable status if the emitter is a major leader at minimum

func (*Session) SetSupervisor

func (s *Session) SetSupervisor(stu string, sup schema.Person) error

SetSupervisor changes the supervisor if the emitter is the student or an admin at minimum

func (*Session) SetSurveyInvitation

func (s *Session) SetSurveyInvitation(student, kind string) (time.Time, error)

SetSurveyInvitation is ok if the emitter is at least an administrator

func (*Session) SetTutor

func (s *Session) SetTutor(stu string, t string) error

SetTutor changes the tutor if the emitter is an admin at minimum

func (*Session) SetUserPerson

func (s *Session) SetUserPerson(p schema.Person) error

SetUserPerson set the user profile if the emitter is the targeted user

func (*Session) SetUserRole

func (s *Session) SetUserRole(email string, priv schema.Role) error

SetUserRole changes the user privileges if the emitter is an admin at minimum and not himself

func (*Session) Student

func (s *Session) Student(stu string) (schema.Student, error)

Student returns the student if the emitter is the student or a watcher

func (*Session) Students

func (s *Session) Students() (schema.Students, error)

Students lists all the students if the emitter is an admin at least

func (*Session) Survey

func (s *Session) Survey(student, kind string) (schema.SurveyHeader, error)

Survey get the given survey for a student if the emitter is the student tutor or a major admin at least

func (*Session) Tutoring

func (s *Session) Tutoring(student string) bool

Tutoring checks if the session owner is a tutor of the given student

func (*Session) UpdateStudentDefense

func (s *Session) UpdateStudentDefense(student string, t time.Time, public, local bool) error

func (*Session) User

func (s *Session) User(em string) (schema.User, error)

User returns a given user if the emitter is himself or an admin

func (*Session) Users

func (s *Session) Users() ([]schema.User, error)

Users lists all the users if the emitter is at least an admin

func (*Session) Watching

func (s *Session) Watching(student string) bool

Watching checks if the student is in the major I am the leader of, an head or not or the student tutor

Jump to

Keyboard shortcuts

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