Last change
on this file since 9050790 was a436340, checked in by Gjoko Kostadinov <gjoko.kostadinov@…>, 17 months ago |
Adding customer registration
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | package edu.gjoko.schedlr.services;
|
---|
2 |
|
---|
3 | import edu.gjoko.schedlr.entity.Stakeholder;
|
---|
4 | import edu.gjoko.schedlr.entity.StakeholderType;
|
---|
5 | import edu.gjoko.schedlr.repositories.StakeholderRepository;
|
---|
6 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
---|
7 | import org.springframework.stereotype.Service;
|
---|
8 |
|
---|
9 | @Service
|
---|
10 | public class StakeholderService {
|
---|
11 |
|
---|
12 | private StakeholderRepository stakeholderRepository;
|
---|
13 | private BCryptPasswordEncoder bCryptPasswordEncoder;
|
---|
14 |
|
---|
15 | public StakeholderService(StakeholderRepository stakeholderRepository,
|
---|
16 | BCryptPasswordEncoder bCryptPasswordEncoder) {
|
---|
17 | this.stakeholderRepository = stakeholderRepository;
|
---|
18 | this.bCryptPasswordEncoder = bCryptPasswordEncoder;
|
---|
19 | }
|
---|
20 |
|
---|
21 | public Stakeholder saveStakeholder(Stakeholder stakeholder) {
|
---|
22 | stakeholder.setPassword(bCryptPasswordEncoder.encode(stakeholder.getPassword()));
|
---|
23 | stakeholder.setStakeholderType(StakeholderType.CUSTOMER);
|
---|
24 | return stakeholderRepository.save(stakeholder);
|
---|
25 | }
|
---|
26 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.