Chapter 25 : issue with "Value of type 'Session' has no member 'set'"

Hi,
I have an issue in Chapter 25 , with the two handlers resetPasswordHandler and resetPasswordPostHandler, I can’t build the project anymore, while it was running before. I tried to add the reset password function (Chapter 25.3) and now I got the two errors by Xcode
…/Sources/App/Controllers/WebsiteController.swift:265:47: Value of type ‘Session’ has no member ‘get’
and
…/Sources/App/Controllers/WebsiteController.swift:238:33: Value of type ‘Session’ has no member ‘set’

I can’t find how to fix after hours spent to search.

From the download materials of the book, I can rebuild without errors the project 25-password-reset-emails/final/TILLApp which includes the two calls of session.get and session.set !

I have checked the source code of

  • Package.swift
  • Configure.swift
  • WebsiteController.swift
  • routes.swift
    without any visible difference, checking packages, imports, compare my functions’ code with the manual, using Xcode to build and test the project. I did clean the cache to rebuild from scratch, same result.

My project is different from the book on the following points

  • no Acronym objects and functions, only Users
  • no Authentication by Google, Apple, GitHub
  • use of MySQL database instead of PostgreSQL

I did a grep -R Session ./** on my folder and the materials : no difference
I did a grep -R session ./** on my folder and the materials : only differences are call for other authentication methods (oAuth, CRSF Token and siwa)

so the question is, where is the declaration of this req.session.get and req.session.set which can explain why the full official project is built without error and mine is crashing.

Should I implement all authentication methods to catch the missing piece of code I can’t find , or the CRSF token ?

any idea would be welcome, I’m lost here and would like to understand.
Meanwhile I’m going forward with my project by deactivation of the ‘forgotten password’ function.:frowning:

@tlepiez the get helpers are defined in Imperial, which you’ll be missing because you skipped the 3rd party auth sections. Copy these lines into your project and it should work!

thank you so much!
I have added the missing code ( whole code of “extension session” in fact), and now it works. :grinning: :grinning:

1 Like