This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vapor new BasicAuth --web | |
cd BasicAuth/ | |
vapor xcode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PackageDescription | |
let package = Package( | |
name: "BasicAuth", | |
targets: [ | |
Target(name: "App"), | |
Target(name: "Run", dependencies: ["App"]), | |
], | |
dependencies: [ | |
.Package(url: "https://github.com/vapor/vapor.git", majorVersion: 2), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"//": "The underlying database technology to use.", | |
"//": "memory: SQLite in-memory DB.", | |
"//": "sqlite: Persisted SQLite DB (configure with sqlite.json)", | |
"//": "Other drivers are available through Vapor providers", | |
"//": "https://github.com/search?q=topic:vapor-provider+topic:database", | |
"driver": "memory", | |
"//": "Naming convention to use for creating foreign id keys,", | |
"//": "e.g., `user_id`", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// User.swift | |
// Bits | |
// | |
// Created by Benjamin Baumann on 05.09.17. | |
// | |
import FluentProvider | |
import HTTP | |
import Fluent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import LeafProvider | |
import FluentProvider | |
extension Config { | |
public func setup() throws { | |
// allow fuzzy conversions for these types | |
// (add your own types here) | |
Node.fuzzy = [JSON.self, Node.self] | |
try setupProviders() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="" method="post"> | |
<input type="hidden" name="type" value="loginUser" /> | |
<input class="u-full-width" type="email" name="email" placeholder="Email" id="linkInput"> | |
<input class="u-full-width" type="password" name="password" placeholder="Password" id="linkInput"> | |
<input class="button-primary" type="submit" value="Register"> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="" method="post"> | |
<input type="hidden" name="type" value="registerUser" /> | |
<input class="u-full-width" type="email" name="email" placeholder="Email" id="linkInput"> | |
<input class="u-full-width" type="text" name="name" placeholder="Name" id="linkInput"> | |
<input class="u-full-width" type="password" name="password" placeholder="Password" id="linkInput"> | |
<input class="button-primary" type="submit" value="Register"> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// GET / | |
builder.get { req in | |
return try self.view.make("welcome") | |
} | |
builder.get("register") { req in | |
return try self.view.make("register") | |
} | |
builder.post("register") { req in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vapor | |
import AuthProvider | |
import Sessions | |
import HTTP | |
final class Routes: RouteCollection { | |
let view: ViewRenderer | |
//route builder for protected routes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@_exported import Vapor | |
extension Droplet { | |
public func setup() throws { | |
let routes = Routes(view,drop: self) | |
try collection(routes) | |
} | |
} |
OlderNewer