From d25e5c7d1a471225bcac3aecd6e58d2326b2d9eb Mon Sep 17 00:00:00 2001 From: adanrsantos Date: Wed, 23 Oct 2024 18:01:27 -0500 Subject: [PATCH 1/5] working on canvas --- static/canvas.js | 125 +++++++++++++---------------------------------- 1 file changed, 35 insertions(+), 90 deletions(-) diff --git a/static/canvas.js b/static/canvas.js index 06df99a..191e672 100644 --- a/static/canvas.js +++ b/static/canvas.js @@ -3,9 +3,39 @@ const ctx = canvas.getContext("2d"); const canvasSize = 500; const dataSize = 1000; +const gridCount = 10 ; canvas.width = canvasSize; canvas.height = canvasSize; +//let pixelSize = canvasSize / dataSize; +let pixelSize = canvasSize / gridCount; +const centerPixel = pixelSize / 2; + +function drawGrid() { + ctx.strokeStyle = '#000'; // Set grid line color + ctx.lineWidth = 1; // Set grid line width + + // Draw horizontal lines + for (let i = 0; i <= gridCount; i++) { + let y = i * pixelSize; + ctx.beginPath(); + ctx.moveTo(0, y); // Start the line at the left edge (x = 0) + ctx.lineTo(canvasSize, y); // Draw to the right edge (x = canvasSize) + ctx.stroke(); + } + + // Draw vertical lines + for (let i = 0; i <= gridCount; i++) { + let x = i * pixelSize; + ctx.beginPath(); + ctx.moveTo(x, 0); // Start the line at the top edge (y = 0) + ctx.lineTo(x, canvasSize); // Draw to the bottom edge (y = canvasSize) + ctx.stroke(); + } +} + +drawGrid(); + class Point { // new Point(x, y) constructor(x, y) { @@ -51,98 +81,13 @@ class Point { } } -let pixelSize = canvasSize / dataSize; -const centerPixel = pixelSize / 2; - -function draw(x, y) { - ctx.fillRect(x, y, pixelSize, pixelSize); +function draw(point) { + ctx.fillRect(point.x, point.y, pixelSize, pixelSize); } canvas.addEventListener("mousedown", (e) => { let x = e.clientX - canvas.getBoundingClientRect().left - centerPixel; let y = e.clientY - canvas.getBoundingClientRect().top - centerPixel; - draw(x, y); -}) - -//const toolbar = document.getElementById("toolbar"); -//const strokePicker = document.getElementById("stroke"); -//const canvasOffsetX = canvas.offsetLeft; -//const canvasOffsetY = canvas.offsetTop; -//canvas.width = 150; -//canvas.height = 150; - -/* -let isPainting = false; -let lineWidth = 5; -let strokeColor = "#000000"; -let startX; -let startY; - -function drawGrid(lineInterval, lineColor) { - // Set the color of the grid lines - ctx.strokeStyle = lineColor; - ctx.lineWidth = 1; // Set the gridline thickness - - // Draw vertical grid lines - for (let x = 0; x <= canvas.width; x += lineInterval) { - ctx.beginPath(); - ctx.moveTo(x, 0); // Start from top of the canvas - ctx.lineTo(x, canvas.height); // Draw line down to the bottom - ctx.stroke(); - } - - // Draw horizontal grid lines - for (let y = 0; y <= canvas.height; y += lineInterval) { - ctx.beginPath(); - ctx.moveTo(0, y); // Start from the left of the canvas - ctx.lineTo(canvas.width, y); // Draw line across to the right - ctx.stroke(); - } - ctx.beginPath(); -} - -// Call the drawGrid function with 50px intervals and a light gray color -drawGrid(10, '#A9A9A9'); - -toolbar.addEventListener("click", e => { - if (e.target.id === "clear"){ - ctx.clearRect(0, 0, canvas.width, canvas.height); - - drawGrid(10, '#A9A9A9'); - } - - if (e.target.id === "lineWidth"){ - lineWidth = e.target.value; - } -}); - -strokePicker.addEventListener("input", (e) => { - strokeColor = e.target.value; -}); - -const draw = (e) => { - if (!isPainting){ - return; - } - ctx.lineWidth = lineWidth; - ctx.strokeStyle = strokeColor; - ctx.lineCap = "round"; - - ctx.lineTo(e.clientX - canvasOffsetX, e.clientY - canvasOffsetY); - ctx.stroke(); -} - -canvas.addEventListener("mousedown", (e) => { - isPainting = true; - startX = e.clientX; - startY = e.clientY; -}); - -canvas.addEventListener("mouseup", (e) => { - isPainting = false; - ctx.stroke(); - ctx.beginPath(); -}); - -canvas.addEventListener("mousemove", draw); -*/ + let point = new Point(x, y) + draw(point); +}); \ No newline at end of file From f3de96ac54a483cde3486703e78d8d83bc66e059 Mon Sep 17 00:00:00 2001 From: Logan Gatlin Date: Wed, 23 Oct 2024 18:09:48 -0500 Subject: [PATCH 2/5] fixed to grid --- email.go | 42 ++++++++++++++++++++++++++++++++++++++++++ go.mod | 6 +++++- go.sum | 4 ++++ server.go | 1 + static/canvas.js | 11 ++++++----- users.go | 22 ++++++++++++++-------- 6 files changed, 72 insertions(+), 14 deletions(-) create mode 100644 email.go diff --git a/email.go b/email.go new file mode 100644 index 0000000..06b0eb8 --- /dev/null +++ b/email.go @@ -0,0 +1,42 @@ +package main + +import ( + "crypto/tls" + "fmt" + "gopkg.in/gomail.v2" + "net/smtp" +) + +func Send(body string) { + from := "xterminate18181@gmail.com" + pass := "nvzp fodm ihzw gter" + to := "joson.anthoney@frontdomain.org" + + msg := "From: " + from + "\n" + + "To: " + to + "\n" + + "Subject: Hello there\n\n" + + body + + err := smtp.SendMail("smtp.gmail.com:587", + smtp.PlainAuth("", from, pass, "smtp.gmail.com"), + from, []string{to}, []byte(msg)) + + if err != nil { + fmt.Printf("smtp error: %s", err) + return + } + fmt.Println("Successfully sended to " + to) +} + +func MailTest() { + d := gomail.NewDialer("smtp.gmail.com", 587, "xterminate18181@gmail.com", "nvzp fodm ihzw gter") + d.TLSConfig = &tls.Config{InsecureSkipVerify: true} + m := gomail.NewMessage() + m.SetHeader("From", "xterminate18181@gmail.com") + m.SetHeader("To", "logan@gatlintc.com") + m.SetHeader("Subject", "Confirm Email") + m.SetBody("text/html", "Test body") + if err := d.DialAndSend(m); err != nil { + panic(err) + } +} diff --git a/go.mod b/go.mod index 55c3846..69ffa76 100644 --- a/go.mod +++ b/go.mod @@ -7,4 +7,8 @@ require ( golang.org/x/crypto v0.27.0 ) -require github.com/gorilla/securecookie v1.1.2 // indirect +require ( + github.com/gorilla/securecookie v1.1.2 // indirect + gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect + gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df // indirect +) diff --git a/go.sum b/go.sum index b04990b..1b240e4 100644 --- a/go.sum +++ b/go.sum @@ -6,3 +6,7 @@ github.com/gorilla/sessions v1.4.0 h1:kpIYOp/oi6MG/p5PgxApU8srsSw9tuFbt46Lt7auzq github.com/gorilla/sessions v1.4.0/go.mod h1:FLWm50oby91+hl7p/wRxDth9bWSuk0qVL2emc7lT5ik= golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= +gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk= +gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk= +gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE= +gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw= diff --git a/server.go b/server.go index d9f2c3b..a3752fe 100644 --- a/server.go +++ b/server.go @@ -20,6 +20,7 @@ type Server struct { } func main() { + Send("test body") // Grab command line arguments ipFlag := flag.String("ip", "127.0.0.1", "IP address to receive traffic from") portFlag := flag.String("port", "8080", "Port to receive traffic from") diff --git a/static/canvas.js b/static/canvas.js index 191e672..5203ebe 100644 --- a/static/canvas.js +++ b/static/canvas.js @@ -45,15 +45,15 @@ class Point { // Convert canvas position to data position canvasToData() { return new Point( - Math.round(this.x / canvasSize * dataSize), - Math.round(this.y / canvasSize * dataSize) + Math.round(this.x / canvasSize * gridCount), + Math.round(this.y / canvasSize * gridCount) ); } // Convert data position to canvas position dataToCanvas() { return new Point( - this.x / dataSize * canvasSize, - this.y / dataSize * canvasSize + this.x / gridCount * canvasSize, + this.y / gridCount * canvasSize ); } // Convert to array index @@ -82,6 +82,7 @@ class Point { } function draw(point) { + point = point.canvasToData().dataToCanvas() ctx.fillRect(point.x, point.y, pixelSize, pixelSize); } @@ -90,4 +91,4 @@ canvas.addEventListener("mousedown", (e) => { let y = e.clientY - canvas.getBoundingClientRect().top - centerPixel; let point = new Point(x, y) draw(point); -}); \ No newline at end of file +}); diff --git a/users.go b/users.go index d9de3e6..329cb7d 100644 --- a/users.go +++ b/users.go @@ -14,6 +14,7 @@ const SESSION_COOKIE_NAME = "utsa-place-session" const SESSION_AUTH = "auth" const SESSION_STARTED = "age" const SESSION_CONFIRMED = "confirmed" +const SESSION_CONFIRM_KEY = "confirm-key" const ENCRYPTION_STRENGTH = 14 @@ -139,15 +140,20 @@ func (s *Server) handle_register(w http.ResponseWriter, r *http.Request) { } func (s *Server) handle_confirmation(w http.ResponseWriter, r *http.Request) { - session, err := s.Sessions.Get(r, SESSION_COOKIE_NAME) - if err != nil { - s.handle_logout(w, r) - http.Redirect(w, r, "/register", http.StatusFound) - return + switch r.Method { + case http.MethodGet: + session, err := s.Sessions.Get(r, SESSION_COOKIE_NAME) + if err != nil { + s.handle_logout(w, r) + http.Redirect(w, r, "/register", http.StatusFound) + return + } + confirmed := session.Values[SESSION_CONFIRMED] + fmt.Println("Session confirmed: ", confirmed) + http.ServeFile(w, r, "./static/confirmation.html") + case http.MethodPost: + default: } - confirmed := session.Values[SESSION_CONFIRMED] - fmt.Println("Session confirmed: ", confirmed) - http.ServeFile(w, r, "./static/confirmation.html") } func (s *Server) secret(w http.ResponseWriter, r *http.Request) { From ac664eddf3b3d36276b18736ef953ee138f91cac Mon Sep 17 00:00:00 2001 From: reddishquill371 Date: Wed, 23 Oct 2024 18:12:27 -0500 Subject: [PATCH 3/5] worked on forgot password page --- static/forgotpassword.css | 47 ++++++++++++++++++++++++++++++++++++++ static/forgotpassword.html | 22 +++++++++++++++++- static/register.html | 2 +- 3 files changed, 69 insertions(+), 2 deletions(-) diff --git a/static/forgotpassword.css b/static/forgotpassword.css index e69de29..cf481db 100644 --- a/static/forgotpassword.css +++ b/static/forgotpassword.css @@ -0,0 +1,47 @@ +:root { + --utsa-orange: #f15a22; + --utsa-blue: #0c2340; +} + +html { + background-color: var(--utsa-orange); +} + +#rform { + border-radius: 10px; + border: solid var(--utsa-orange) 2px; + margin: 100px; + padding: 30px; + background-color: white; +} + +#formbg { + background-color: var(--utsa-orange); +} + +#h3bg { + background-color: var(--utsa-blue); +} + +h3 { + border-radius: 10px; + padding: 20px; + margin: 10px; + background-color: var(--utsa-blue); + color: var(--utsa-orange); + font-size: 40px; + font-family: Verdana, Geneva, Tahoma, sans-serif; +} + +.form-label { + font-family: Verdana, Geneva, Tahoma, sans-serif; +} + +.form-control { + font-family: Verdana, Geneva, Tahoma, sans-serif; +} + +.form-text { + padding: 3px; + font-family: Verdana, Geneva, Tahoma, sans-serif; +} \ No newline at end of file diff --git a/static/forgotpassword.html b/static/forgotpassword.html index cf8c163..6051400 100644 --- a/static/forgotpassword.html +++ b/static/forgotpassword.html @@ -10,6 +10,26 @@ - +

UTSA Place

+
+
+
+ Forgot Password +
+

+
+ + +
Enter your email and we will send you a 6-digit recovery code.
+
+ +
+
+ + Click here to go back to login. + +
+
+
\ No newline at end of file diff --git a/static/register.html b/static/register.html index 2a566b3..5de67c3 100644 --- a/static/register.html +++ b/static/register.html @@ -35,7 +35,7 @@

- + From 09602d48f1c3e1114045446f4cc3c4b5f4926777 Mon Sep 17 00:00:00 2001 From: reddishquill371 Date: Wed, 23 Oct 2024 18:26:12 -0500 Subject: [PATCH 4/5] reverted unnecessary changes to register.html --- static/register.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/register.html b/static/register.html index 5de67c3..2a566b3 100644 --- a/static/register.html +++ b/static/register.html @@ -35,7 +35,7 @@

- + From 502a87ef2458b4a44a2a0ee0529b7ab6bcb552a9 Mon Sep 17 00:00:00 2001 From: reddishquill371 Date: Wed, 23 Oct 2024 18:32:02 -0500 Subject: [PATCH 5/5] added links for forgotpassword page and confirmation page --- static/index.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/static/index.html b/static/index.html index 66c10d2..21eff23 100644 --- a/static/index.html +++ b/static/index.html @@ -20,6 +20,12 @@
  • Login
  • +
  • + Forgot Password +
  • +
  • + Confirmation +
  • Log Out