Skip to content

Instantly share code, notes, and snippets.

View bennibau's full-sized avatar
🏠
Working from home

bennibau

🏠
Working from home
View GitHub Profile
[
{
"id": "8A5B3531-4B20-4F08-8167-79701AFAC748",
"name": "user1@gmail.com"
},
{
"id": "48023C64-8D76-4E39-865C-04DD95C1FA6C",
"name": "user2@gmail.com"
},
{
let mappedUsers = allUsers.map { users -> [UserDto] in
var userContainer = [UserDto]()
users.forEach({ user in
userContainer.append(UserDto(id: user.id, name: user.email))
})
return userContainer
}
//
// RESTController.swift
// App
//
// Created by Benjamin Baumann on 06.07.18.
//
import Foundation
import Vapor
import Authentication
//
// State.swift
// App
//
// Created by Benjamin Baumann on 28.09.17.
//
import Vapor
import FluentProvider
import HTTP
//
// Capital.swift
// App
//
// Created by Benjamin Baumann on 28.09.17.
//
import Vapor
import FluentProvider
import HTTP
//
// Country.swift
// App
//
// Created by Benjamin Baumann on 28.09.17.
//
import Vapor
import FluentProvider
import HTTP
//1. Modify this controller to be built by "authRoutes" to protect all it's routes
/// GET /hello/...
authRoutes.resource("hello", HelloController(view))
//2. create the login route
builder.get("login") { req in
return try self.view.make("login")
}
//3. implement the login logic, built by the "loginRouteBuilder" so our session is persisted
@_exported import Vapor
extension Droplet {
public func setup() throws {
let routes = Routes(view,drop: self)
try collection(routes)
}
}
import Vapor
import AuthProvider
import Sessions
import HTTP
final class Routes: RouteCollection {
let view: ViewRenderer
//route builder for protected routes
/// 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