Skip to content

Instantly share code, notes, and snippets.

@eminetto
Created June 4, 2019 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eminetto/dcc131f3a762e88fddaf6d624868cfae to your computer and use it in GitHub Desktop.
Save eminetto/dcc131f3a762e88fddaf6d624868cfae to your computer and use it in GitHub Desktop.
package login
import (
"github.com/user/project/user/repository"
)
type loginService struct {
userRepository *repository.UserRepository
}
func NewLoginService() *loginService {
return &loginService{
userRepository: repository.NewUserRepository(),
}
}
func (l *loginService) Login(userName, password string) {
if l.userRepository.IsValid(userName, password) {
redirect("homepage")
} else {
addFlash("error", "Bad credentials")
redirect("login")
}
}
func redirect(page string) {
// redirect to given page
}
func addFlash(msgType, msg string) {
// create flash message
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment