-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Rahaf Aljerwi on 9/16/24. | ||
// | ||
|
||
import Foundation |
16 changes: 16 additions & 0 deletions
16
Sources/App/Controllers/Authentication/PortalController.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// PortalController.swift | ||
// | ||
// | ||
|
||
|
||
import Fluent | ||
import Plot | ||
import Vapor | ||
|
||
enum PortalController { | ||
@Sendable | ||
static func show(req: Request) async throws -> HTML { | ||
return Portal.View(path: req.url.path).document() | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
Sources/App/Controllers/Authentication/SignupController.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Rahaf Aljerwi on 9/14/24. | ||
// | ||
|
||
import Foundation |
8 changes: 8 additions & 0 deletions
8
Sources/App/Controllers/Authentication/VerifyController.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Rahaf Aljerwi on 9/15/24. | ||
// | ||
|
||
import Foundation |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// | ||
// PortalView.swift | ||
// | ||
// | ||
|
||
import Plot | ||
import Foundation | ||
|
||
enum Portal { | ||
|
||
class View: PublicPage { | ||
|
||
// let model: Model | ||
|
||
// init(path: String, model: Model) { | ||
// self.model = model | ||
// super.init(path: path) | ||
// } | ||
|
||
override func pageTitle() -> String? { | ||
"Portal" | ||
} | ||
|
||
override func content() -> Node<HTML.BodyContext> { | ||
.div( | ||
.h2("Login"), | ||
.loginForm(), | ||
.h2("Dont have an account?"), | ||
.signupButton() | ||
) | ||
} | ||
} | ||
} | ||
|
||
// move to other file later | ||
extension Portal { | ||
struct Model { | ||
var email: String | ||
var password: String | ||
} | ||
} | ||
|
||
// move to plot extensions later | ||
extension Node where Context: HTML.BodyContext { | ||
static func loginForm(email: String = "", password: String = "") -> Self { | ||
.form( | ||
.action(SiteURL.portal.relativeURL()), | ||
.loginField(email: email), | ||
.passwordField(password: password), | ||
.button( | ||
.type(.submit) | ||
) | ||
) | ||
} | ||
|
||
static func signupButton() -> Self { | ||
.form( | ||
.action(SiteURL.signup.relativeURL()), | ||
.button( | ||
.type(.submit) | ||
) | ||
) | ||
} | ||
} | ||
|
||
extension Node where Context == HTML.FormContext { | ||
static func loginField(email: String = "") -> Self { | ||
.input( | ||
.id("email"), | ||
.name("email"), | ||
.type(.email), | ||
.placeholder("Enter email"), | ||
.spellcheck(false), | ||
.autocomplete(false), | ||
.value(email) | ||
) | ||
} | ||
|
||
static func passwordField(password: String = "") -> Self { | ||
.input( | ||
.id("password"), | ||
.name("password"), | ||
.type(.password), | ||
.placeholder("Enter password"), | ||
.spellcheck(false), | ||
.autocomplete(false), | ||
.value(password) | ||
) | ||
} | ||
} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Rahaf Aljerwi on 9/16/24. | ||
// | ||
|
||
import Foundation |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// | ||
// File 2.swift | ||
// | ||
// | ||
// Created by Rahaf Aljerwi on 9/14/24. | ||
// | ||
|
||
import Foundation |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// | ||
// File 2.swift | ||
// | ||
// | ||
// Created by Rahaf Aljerwi on 9/16/24. | ||
// | ||
|
||
import Foundation |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Rahaf Aljerwi on 9/15/24. | ||
// | ||
|
||
import Foundation |