Closed FranEnLaNube closed 7 months ago
Kudos, SonarCloud Quality Gate passed!
0 Bugs
0 Vulnerabilities
0 Security Hotspots
2 Code Smells
No Coverage information
0.7% Duplication
app.php
to follow PER rules.passport:install
in \Artisan::call('passport:install');
: I've tried to move it to the beginning of the class with a setup
or setupBeforeClass
method. But, it couldn't guarantee to be ran when a specific test is called.'message' => __('auth.failed')
but, as we have personalized JSON response in our AuthController
they didn't match.Need @androsrivas check when its possible.
First of all, @franenlanube THANK YOU for the huge explanations, that is a very generous use of a Pull Request.
About the feature:
Congratulations!
Great job @franenlanube ! Last Sunday I noticed that there was no Logout method in AuthController. Luckily, that can be fixed quickly! Thank you for such a thorough PR!!
There are different ways to solve this.
Also there are two ways to do it.
After talk about this in the meeting we decided to do a specific one because the application is already in production and we want to use the benefits of migrations history.
These are the articles I've read to support this task.
Changes
Added a new specific migration:
2023_11_13_160349_add_last_login_at_to_users.php
up()
Ads a columnlast_login_at
, nullable, after the role one.->nullable()
are used to add characteristics to a field.down()
To revert this migration by deleting this column.User.php
To be able to useupdate()
in the controller I've addedlast_login_at
field to$fillable [ ]
$user->last_login_at = now(); $user->save();
AuthController.php
-Atlogin()
I added$user->update(['last_login_at' => now()]);
, the field isNULL
when a new user is created. -Also could use=> Carbon::now()
or=> new DateTime()
, first one it's just the long way and second is another class which to the same. Like it's said hereAnnotationsUser.php
Addlast_login_at
field to user swagger annotations.config/app.php
Set new timezone following.env
variable, we'll need to set this in the.env
file with a variable like this one:APP_TIMEZONE='Europe/Madrid'
LoginTest.php
Two more tests to check if the field is updated when a user is logged and if is not when login failsOthers PR related with this issue
Testing
PR #50 and PR #55 about login testing. https://github.com/IT-Academy-BCN/ita-landing-backend/pull/50 y https://github.com/IT-Academy-BCN/ita-landing-backend/pull/55
Migrations
PR #49 modification of create_users_table https://github.com/IT-Academy-BCN/ita-landing-backend/pull/49
PR #56 modification of create_faqs_table and create_apps_table migrations. https://github.com/IT-Academy-BCN/ita-landing-backend/pull/55
PR #62 modification of retet_tokens_table migration. https://github.com/IT-Academy-BCN/ita-landing-backend/pull/62
PR #73 modification of create_codes_table migration. https://github.com/IT-Academy-BCN/ita-landing-backend/pull/73
PR #89 make add-column-to-apps migration. https://github.com/IT-Academy-BCN/ita-landing-backend/pull/89
Comments