Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: invite user by email #35

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
479e2d8
Add Send email function
cedricve Jun 12, 2024
57c1194
add templates for welcome, forgot password and onboarding + add email…
cedricve Jun 12, 2024
06dae08
add invite template
cedricve Jun 26, 2024
9244d19
add example .env file
cedricve Jun 26, 2024
a13bbea
add invite template
cedricve Jun 26, 2024
fe1868c
change typo + remove __debug files
cedricve Jun 26, 2024
2436b98
Merge branch 'main' into feature-invite-user
cedricve Jun 26, 2024
d676da4
add details about backend
cedricve Jun 27, 2024
11e0322
fix invite
cedricve Jun 27, 2024
1bcf435
Update .gitignore
cedricve Jun 27, 2024
e197d6f
add encryption method
cedricve Jun 27, 2024
b029c63
Update styling of invite.go
LuisMaja Jun 27, 2024
c629fcc
Merge branch 'feature-invite-user' of https://github.com/uug-ai/facia…
LuisMaja Jun 27, 2024
dc1b72c
add new ENV variables + fingerprint generation
cedricve Jun 27, 2024
fa3899e
Update users.go
cedricve Jun 27, 2024
a0255ef
Update users.go
cedricve Jun 27, 2024
8eff037
Merge branch 'main' into feature-invite-user
cedricve Jun 27, 2024
bcdd868
Add InviteUser in frontend
KilianBoute Jun 27, 2024
664e182
Delete .env from git
KilianBoute Jun 27, 2024
1261384
Merge branch 'feature-invite-user' of github.com:uug-ai/facial-access…
KilianBoute Jun 27, 2024
8e1c94c
Update styling of invite.go
LuisMaja Jun 27, 2024
3513d6e
Merge branch 'feature-invite-user' of https://github.com/uug-ai/facia…
LuisMaja Jun 27, 2024
0201773
Add status and videoPath to users, show status, invite and add users
KilianBoute Jun 27, 2024
4e51692
Merge branch 'feature-invite-user' of github.com:uug-ai/facial-access…
KilianBoute Jun 27, 2024
526920c
Add decryption from onboarding token
KilianBoute Jun 28, 2024
20b50ef
generate token differently
cedricve Jun 28, 2024
94de2ea
Decrypt token and add values to form
KilianBoute Jul 1, 2024
dac3913
Remove env.local from git
KilianBoute Jul 1, 2024
096634a
Make private key handling server sided
KilianBoute Jul 1, 2024
1203129
Fix typo in .env.production
KilianBoute Jul 1, 2024
de27896
Adjust Invite user to be provide access to added user
KilianBoute Jul 1, 2024
defa578
Add update user to onboarding
KilianBoute Jul 2, 2024
2d39307
Replace updateUser with onboardUser
KilianBoute Jul 2, 2024
38b04d9
Adjust onboarding form to send video as well
KilianBoute Jul 9, 2024
00a7f3c
Add recording indicator
KilianBoute Jul 9, 2024
a310fbc
Onboarding page refactor start
KilianBoute Jul 11, 2024
5ca32e3
Add onboarding demo animation
KilianBoute Jul 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ ml/data/test_images
node_modules
ui/out
__debug_bin*
api/__debug_bin*
api/.env.local
api/__debug_bin*
ui/yarn.lock
api/.env
ui/.env.local
ui/.env.local
*.local
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ The front-end makes use of the [Next.js](https://nextjs.org/) framework. [Storyb

The back-end or API is written in Golang, and defines specific methods to persist data and call the face recognition model. It has various API methods to create new users, assign permissions and access control, and (re)train and interfere with the facial recognition model.

- Swagger API is hosted at http://localhost:80/swagger/index.html
- Postman Collection [can be found here](https://kerberosio.postman.co/workspace/UUG.AI~52218588-948a-49a0-8046-34f96285bd19/collection/5538769-9f1fc117-a30b-4acf-a7f4-e7ca1ebe5d6f?action=share&creator=5538769)

## ML (face recognition)

To be documented
Expand Down
2 changes: 0 additions & 2 deletions api/.env

This file was deleted.

2 changes: 0 additions & 2 deletions api/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [


{
"name": "Launch Package",
"type": "go",
Expand Down
85 changes: 85 additions & 0 deletions api/controllers/email.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package controllers

import (
"log"
"os"

"github.com/uug-ai/facial-access-control/api/models"
"github.com/uug-ai/facial-access-control/api/notifications"
)

type Email struct {
Type string
Mailgun notifications.Mail
SMTP notifications.SMTP
}

func (email Email) Send(m notifications.Message) {
if email.Type == "mailgun" {
err := email.Mailgun.Send(m) // TODO add error handler
if err != nil {
log.Println(err)
}
} else if email.Type == "smtp" {
err := email.SMTP.Send(m) // TODO add error handler
if err != nil {
log.Println(err)
}
}
}

func Mail(mailto string, template string) *Email {
emailProvider := os.Getenv("MAIL_PROVIDER")
if emailProvider == "" {
emailProvider = "mailgun"
}
var email Email
if emailProvider == "mailgun" {
mailgun := notifications.Mail{
Domain: os.Getenv("MAILGUN_DOMAIN"),
ApiKey: os.Getenv("MAILGUN_API_KEY"),
EmailFrom: os.Getenv("EMAIL_FROM"),
EmailTo: mailto,
TemplateId: template,
}
email.Type = "mailgun"
email.Mailgun = mailgun
} else if emailProvider == "smtp" {
smtp := notifications.SMTP{
Server: os.Getenv("SMTP_SERVER"),
Port: os.Getenv("SMTP_PORT"),
Username: os.Getenv("SMTP_USERNAME"),
Password: os.Getenv("SMTP_PASSWORD"),
EmailFrom: os.Getenv("EMAIL_FROM"),
EmailTo: mailto,
TemplateId: template,
}
email.Type = "smtp"
email.SMTP = smtp
}
return &email
}

func SendWelcomeEmail(user models.User, m notifications.Message) {
m.Title = os.Getenv("WELCOME_TITLE")
email := Mail(user.Email, os.Getenv("WELCOME_TEMPLATE"))
email.Send(m)
}

func SendShareEmail(user models.User, m notifications.Message) {
m.Title = os.Getenv("SHARE_TITLE")
email := Mail(user.Email, os.Getenv("SHARE_TEMPLATE"))
email.Send(m) // TODO add error handler
}

func SendActivationEmail(user models.User, m notifications.Message) {
m.Title = os.Getenv("ACTIVATE_TITLE")
email := Mail(user.Email, os.Getenv("ACTIVATE_TEMPLATE"))
email.Send(m) // TODO add error handler
}

func SendForgotEmail(user models.User, m notifications.Message) {
m.Title = os.Getenv("FORGOT_TITLE")
email := Mail(user.Email, os.Getenv("FORGOT_TEMPLATE"))
email.Send(m) // TODO add error handler
}
Loading
Loading