-
Notifications
You must be signed in to change notification settings - Fork 2
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks very good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should note that documenting your functions is an extremely important step in your code. Especially in Golang since the syntax isn't as readable as other languages. You can take Go's own documentation as reference and keep that in mind.
authMiddleware, err := middleware.NewAuthMiddleware() | ||
if err != nil { | ||
c.Status(500) | ||
log.Fatal("JWT Error:" + err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Fatal
will crash your code. According to their documentation, it will log.Print
then it will os.Exit(1)
. You shouldn't crash your code in the case of a failed Middleware Authentication
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so in here I just use the regular print?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your common log.Printf
will work, and whenever you purposefully want to break the execution of your code, use panic
or os.Exit(1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've fix it with regular print
result, err := loginController.Login() | ||
|
||
if err != nil { | ||
log.Panicln("failed to fetch login cookie") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Panicln
will print your message then call the panic
function, which, in summary, will also crash your program. I don't see the need to crash the program in the case of any malfunctions occurring in the login function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as here, do I just use the regular print? Is there any rule that I have to fellow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. Pretty much the same as the previous comment.
I think for the meantime this is okay, but we will have to tackle it in the Issue concerning Error Handling.
@thelebdev I will open another issue to document this project. Is there any detail that I gotta know? |
@jamfly we can open the issue for now and then we'll go through the details. Maybe adopt some sort of convention |
@thelebdev I've opened issue #28, could you mend up some detail in that issue? I believe we need some sort of function/interface/struct doc convention. |
Description
as title add jwt support for auth management
Fixes #13
Type of Change
Test Cases
targetStudentID
year
semester
to get coursestargetStudentID
to get curriculum semester/login
/auth/curriculums/courses
/auth/curriculums/semesters