File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { Controller , Get } from '@nestjs/common' ;
22import { AppService } from './app.service' ;
3+ import { Public } from './auth/decorators/public.decorator' ;
34
45@Controller ( )
56export class AppController {
67 constructor ( private readonly appService : AppService ) { }
78
9+ @Public ( )
810 @Get ( )
911 getHello ( ) : string {
1012 return this . appService . getHello ( ) ;
Original file line number Diff line number Diff line change @@ -27,6 +27,13 @@ export interface AuthResponse {
2727 refreshToken : string ;
2828}
2929
30+ // Hash of a throwaway password, compared against when the email is unknown so
31+ // that "no such account" and "wrong password" cost the same bcrypt work.
32+ const TIMING_EQUALISATION_HASH = bcrypt . hashSync (
33+ 'timing-equalisation-password' ,
34+ 12 ,
35+ ) ;
36+
3037@Injectable ( )
3138export class AuthService {
3239 private readonly logger = new Logger ( AuthService . name ) ;
@@ -41,7 +48,10 @@ export class AuthService {
4148
4249 async validateUser ( email : string , password : string ) : Promise < User | null > {
4350 const user = await this . usersService . findByEmail ( email ) ;
44- if ( ! user ) return null ;
51+ if ( ! user ) {
52+ await this . usersService . verifyPassword ( password , TIMING_EQUALISATION_HASH ) ;
53+ return null ;
54+ }
4555 const isMatch = await this . usersService . verifyPassword (
4656 password ,
4757 user . passwordHash ,
Original file line number Diff line number Diff line change @@ -486,6 +486,31 @@ export class ShipmentsService {
486486 } ;
487487 }
488488
489+ /**
490+ * Public tracking view: status and route only. The full shipment (price,
491+ * cargo description, notes, party records) is never returned here.
492+ */
493+ async findByTracking ( trackingNumber : string ) {
494+ const shipment = await this . shipmentRepo . findOne ( {
495+ where : { trackingNumber } ,
496+ } ) ;
497+ if ( ! shipment ) {
498+ throw new NotFoundException (
499+ `No shipment found for tracking number ${ trackingNumber } ` ,
500+ ) ;
501+ }
502+ return {
503+ trackingNumber : shipment . trackingNumber ,
504+ status : shipment . status ,
505+ origin : shipment . origin ,
506+ destination : shipment . destination ,
507+ pickupDate : shipment . pickupDate ,
508+ estimatedDeliveryDate : shipment . estimatedDeliveryDate ,
509+ actualDeliveryDate : shipment . actualDeliveryDate ,
510+ updatedAt : shipment . updatedAt ,
511+ } ;
512+ }
513+
489514 async update (
490515 id : string ,
491516 shipperId : string ,
Original file line number Diff line number Diff line change @@ -50,7 +50,12 @@ export class User {
5050 } )
5151 refreshToken : string | null ;
5252
53- @Column ( { name : 'verification_token' , nullable : true , type : 'varchar' } )
53+ @Column ( {
54+ name : 'verification_token' ,
55+ nullable : true ,
56+ type : 'varchar' ,
57+ select : false ,
58+ } )
5459 verificationToken : string | null ;
5560
5661 @Column ( {
You can’t perform that action at this time.
0 commit comments