Created
June 4, 2019 02:14
-
-
Save eminetto/dcc131f3a762e88fddaf6d624868cfae to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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