2021-02-07 22:05:09 +01:00
// Vikunja is a to-do list application to facilitate your life.
// Copyright 2018-2021 Vikunja and contributors. All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public Licensee as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public Licensee for more details.
//
// You should have received a copy of the GNU Affero General Public Licensee
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package user
import (
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/notifications"
)
// EmailConfirmNotification represents a EmailConfirmNotification notification
type EmailConfirmNotification struct {
2021-07-13 22:56:02 +02:00
User * User
IsNew bool
ConfirmToken string
2021-02-07 22:05:09 +01:00
}
// ToMail returns the mail notification for EmailConfirmNotification
func ( n * EmailConfirmNotification ) ToMail ( ) * notifications . Mail {
subject := n . User . GetName ( ) + ", please confirm your email address at Vikunja"
if n . IsNew {
subject = n . User . GetName ( ) + " + Vikunja = <3"
}
nn := notifications . NewMail ( ) .
Subject ( subject ) .
Greeting ( "Hi " + n . User . GetName ( ) + "," )
if n . IsNew {
nn . Line ( "Welcome to Vikunja!" )
}
return nn .
Line ( "To confirm your email address, click the link below:" ) .
2021-07-13 22:56:02 +02:00
Action ( "Confirm your email address" , config . ServiceFrontendurl . GetString ( ) + "?userEmailConfirm=" + n . ConfirmToken ) .
2021-02-07 22:05:09 +01:00
Line ( "Have a nice day!" )
}
// ToDB returns the EmailConfirmNotification notification in a format which can be saved in the db
func ( n * EmailConfirmNotification ) ToDB ( ) interface { } {
return nil
}
2021-02-21 15:50:34 +01:00
// Name returns the name of the notification
func ( n * EmailConfirmNotification ) Name ( ) string {
return ""
}
2021-02-07 22:05:09 +01:00
// PasswordChangedNotification represents a PasswordChangedNotification notification
type PasswordChangedNotification struct {
User * User
}
// ToMail returns the mail notification for PasswordChangedNotification
func ( n * PasswordChangedNotification ) ToMail ( ) * notifications . Mail {
return notifications . NewMail ( ) .
Subject ( "Your Password on Vikunja was changed" ) .
Greeting ( "Hi " + n . User . GetName ( ) + "," ) .
Line ( "Your account password was successfully changed." ) .
Line ( "If this wasn't you, it could mean someone compromised your account. In this case contact your server's administrator." )
}
// ToDB returns the PasswordChangedNotification notification in a format which can be saved in the db
func ( n * PasswordChangedNotification ) ToDB ( ) interface { } {
return nil
}
2021-02-21 15:50:34 +01:00
// Name returns the name of the notification
func ( n * PasswordChangedNotification ) Name ( ) string {
return ""
}
2021-02-07 22:05:09 +01:00
// ResetPasswordNotification represents a ResetPasswordNotification notification
type ResetPasswordNotification struct {
2021-07-13 22:56:02 +02:00
User * User
Token * Token
2021-02-07 22:05:09 +01:00
}
// ToMail returns the mail notification for ResetPasswordNotification
func ( n * ResetPasswordNotification ) ToMail ( ) * notifications . Mail {
return notifications . NewMail ( ) .
Subject ( "Reset your password on Vikunja" ) .
Greeting ( "Hi " + n . User . GetName ( ) + "," ) .
Line ( "To reset your password, click the link below:" ) .
2021-07-13 22:56:02 +02:00
Action ( "Reset your password" , config . ServiceFrontendurl . GetString ( ) + "?userPasswordReset=" + n . Token . Token ) .
Line ( "This link will be valid for 24 hours." ) .
2021-02-07 22:05:09 +01:00
Line ( "Have a nice day!" )
}
// ToDB returns the ResetPasswordNotification notification in a format which can be saved in the db
func ( n * ResetPasswordNotification ) ToDB ( ) interface { } {
return nil
}
2021-02-21 15:50:34 +01:00
// Name returns the name of the notification
func ( n * ResetPasswordNotification ) Name ( ) string {
return ""
}
2021-07-29 18:05:25 +02:00
// InvalidTOTPNotification represents a InvalidTOTPNotification notification
type InvalidTOTPNotification struct {
User * User
}
// ToMail returns the mail notification for InvalidTOTPNotification
func ( n * InvalidTOTPNotification ) ToMail ( ) * notifications . Mail {
return notifications . NewMail ( ) .
Subject ( "Someone just tried to login to your Vikunja account, but failed" ) .
Greeting ( "Hi " + n . User . GetName ( ) + "," ) .
Line ( "Someone just tried to log in into your account with correct username and password but a wrong TOTP passcode." ) .
Line ( "**If this was not you, someone else knows your password. You should set a new one immediately!**" ) .
Action ( "Reset your password" , config . ServiceFrontendurl . GetString ( ) + "get-password-reset" )
}
// ToDB returns the InvalidTOTPNotification notification in a format which can be saved in the db
func ( n * InvalidTOTPNotification ) ToDB ( ) interface { } {
return nil
}
// Name returns the name of the notification
func ( n * InvalidTOTPNotification ) Name ( ) string {
return "totp.invalid"
}
2021-07-29 18:45:22 +02:00
// PasswordAccountLockedAfterInvalidTOTOPNotification represents a PasswordAccountLockedAfterInvalidTOTOPNotification notification
type PasswordAccountLockedAfterInvalidTOTOPNotification struct {
User * User
}
// ToMail returns the mail notification for PasswordAccountLockedAfterInvalidTOTOPNotification
func ( n * PasswordAccountLockedAfterInvalidTOTOPNotification ) ToMail ( ) * notifications . Mail {
return notifications . NewMail ( ) .
Subject ( "We've disabled your account on Vikunja" ) .
Greeting ( "Hi " + n . User . GetName ( ) + "," ) .
Line ( "Someone tried to log in with your credentials but failed to provide a valid TOTP passcode." ) .
Line ( "After 10 failed attempts, we've disabled your account and reset your password. To set a new one, follow the instructions in the reset email we just sent you." ) .
Line ( "If you did not receive an email with reset instructions, you can always request a new one at [" + config . ServiceFrontendurl . GetString ( ) + "get-password-reset](" + config . ServiceFrontendurl . GetString ( ) + "get-password-reset)." )
}
// ToDB returns the PasswordAccountLockedAfterInvalidTOTOPNotification notification in a format which can be saved in the db
func ( n * PasswordAccountLockedAfterInvalidTOTOPNotification ) ToDB ( ) interface { } {
return nil
}
// Name returns the name of the notification
func ( n * PasswordAccountLockedAfterInvalidTOTOPNotification ) Name ( ) string {
return "password.account.locked.after.invalid.totop"
}