madsodgaard / vapor-auth-template Goto Github PK
View Code? Open in Web Editor NEWA Vapor 4 template with authentication, Fluent, JWT, Queues, repository pattern, testing and more.
License: MIT License
A Vapor 4 template with authentication, Fluent, JWT, Queues, repository pattern, testing and more.
License: MIT License
I get 4 errors out of the box,
Undeclared type FieldProtocol
and Value is not a member of type Field.
In UserRepository.swift
Having issues with the existing dockerfiles and getting my app dockerized on a droplet,
I've confirmed vapor-beta's template works with my configuration following the docs.
Some images are different.
I was wondering what function the verify reset password endpoint fills
/api/auth/reset-password/verify
It simply deletes a reset password token?
It would error out much earlier if it were an empty string.
Sure, I should remember all the config steps including customizing that, but if it is missed it will cause auth errors that are not obvious.
import Fluent
struct CreateEmailToken: Migration {
func prepare(on database: Database) -> EventLoopFuture<Void> {
return database.schema("user_email_tokens")
.id()
.field("user_id", .uuid, .required, .references("users", "id", onDelete: .cascade))
.field("token", .string, .required)
.field("expires_at", .datetime, .required)
.unique(on: "user_id")
.unique(on: "token")
.create()
}
func revert(on database: Database) -> EventLoopFuture<Void> {
return database.schema("user_email_tokens").delete()
}
}
Should be removed .unique(on: "user_id")
Hi Mads
Thank you for a great template that saved me many hours of coding, if you have some time I would appreciate your thoughts on how you would implement sessions so that i also can use this template to serve protected sites. I'm interested in how you would go about it using the architecture you are already using.
Thank you in advance.
There's a bit of code I don't understand, on
var repositories: Repositories {
.init(app: self)
}
This results in Repositories
being instantiated on every access.
If you enable log level debug, the template as is does not configure the queue for refreshInterval.
In my app this caused 10Hz of redis messages making debugging impossible.
I've tested a fix
app.queues.configuration.refreshInterval = .minutes(2)
or something reasonable resolves the issues making other logs visible and decluttering the log.
In Xcode 12b6, this file has warnings:
Tests/AppTests/Helpers/XCTAssertResponseError.swift:5:52: Parameter 'file' with default argument '#file' passed to parameter 'file', whose default argument is '#filePath'
Tests/AppTests/Helpers/XCTAssertResponseError.swift:4:93: Did you mean for parameter 'file' to default to '#filePath'?
Tests/AppTests/Helpers/XCTAssertResponseError.swift:5:52: Add parentheses to silence this warning
Tests/AppTests/Helpers/XCTAssertResponseError.swift:5:52: 'file' declared here
Tests/AppTests/Helpers/XCTAssertResponseError.swift:7:72: Parameter 'file' with default argument '#file' passed to parameter 'file', whose default argument is '#filePath'
Tests/AppTests/Helpers/XCTAssertResponseError.swift:4:93: Did you mean for parameter 'file' to default to '#filePath'?
Tests/AppTests/Helpers/XCTAssertResponseError.swift:7:72: Add parentheses to silence this warning
Tests/AppTests/Helpers/XCTAssertResponseError.swift:7:72: 'file' declared here
Tests/AppTests/Helpers/XCTAssertResponseError.swift:8:65: Parameter 'file' with default argument '#file' passed to parameter 'file', whose default argument is '#filePath'
Tests/AppTests/Helpers/XCTAssertResponseError.swift:4:93: Did you mean for parameter 'file' to default to '#filePath'?
Tests/AppTests/Helpers/XCTAssertResponseError.swift:8:65: Add parentheses to silence this warning
Tests/AppTests/Helpers/XCTAssertResponseError.swift:8:65: 'file' declared here
/Users/jimmyhoughjr/vapor-auth-template/Sources/App/Jobs/EmailJob.swift:47:14: Value of type 'Self' has no member 'hopped'
I ran swift package update then swift build in command line. Then built in Xcode with the same error.
For about 2 weeks roughly,Test Suite 'All tests' failed at 2020-09-24 10:25:12.905.
Executed 43 tests, with 18 tests skipped and 37 failures (37 unexpected) in 3.790 (3.794) seconds
I suspect it is due to deps changing or something.
I've been trying to fix them off and on, without success.
We know that hash is a time-consuming operation, why not first confirm whether there is a user?
return User.query(on: req.db)
.filter(\.$email == registerRequest.email)
.first()
.flatMap { (result) -> EventLoopFuture<Void> in
if let _ = result {
return req.eventLoop.makeFailedFuture(AuthenticationError.emailAlreadyExists)
}
do {
let user = try User(from: registerRequest, hash: Bcrypt.hash(registerRequest.password))
return user.save(on: req.db)
.flatMap { (void) -> EventLoopFuture<Void> in
return req.emailVerifier.verify(for: user)
}
} catch {
return req.eventLoop.makeFailedFuture(error)
}
}
.transform(to: .created)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.