Skip to content

bm.do('auth:register') ​

jsx

try {
  // <data value="$policy.auth"/> 를 통해 가입 필요 정책 확인
  const {
    customerFields,
    identityVerificationScopes
  } = bm.context.policy.auth;
  const verificationRequired = identityVerificationScopes.includes('auth:register');

  // bm.do('address:search') 를 통해 조회한 주소 정보
  const address = { ... };

  const identity = verificationRequired ?
    // 본인인증이 필요한 경우, 본인인증 절차를 진행하고 결과를 조회
    await bm.do('auth:verifyIdentity') :
    // 본인인증 미사용 시 폼을 통해 직접 입력받은 값 사용
    { ... };
  
  if (!identity) {
    // 본인인증 절차가 취소된 경우 처리
    ...
  }

  const registration = {
    name: identity.name,
    mobile: identity.mobile,
    birthdate: identity.birthdate,
    gender: identity.gender,
    email: 'hello@example.com',
    password: 'ABCD1234',
    address: {
      postcode: address.postcode,
      city: address.city,
      address1: address.address1,
      address2: '...' // 상세 주소는 직접 입력받은 값 사용
    },
    agreements: {
      MarketingByEmail: true,
      MarketingByOnlineMessenger: true,
      MarketingBySMS: true
    }
  };

  if (verificationRequired) {
    // 본인인증이 필요한 경우, 인증 절차를 통해 발급받은 토큰을 함께 전달
    registration.identityToken = identity.identityToken;
  }

  // 가입 정보 검증
  for (const [field, config] of Object.entries(customerFields)) {
    ...
  }

  await bm.do('auth:register', registration);
  bm.do('snackbar:open', { message: '회원가입이 완료되었어요.' });
  
} catch (err) {
  bm.do('snackbar:open', { message: err.message });
}

주소 검색과 본인인증 결과를 활용해 회원가입을 진행하는 예시

jsx
await bm.do('auth:register', {
  name: {
    full: '...'          // (필수) 이름
  },
  email: '...',           // (필수) 이메일
  password: '...',        // (필수) 비밀번호
  mobile: '01012345678',  // (조건부) 휴대폰 번호
  birthdate: {            // (조건부) 생년월일
    year: 2000,
    month: 1,
    day: 1
  },
  gender: 'male' | 'female', // (조건부) 성별
  address: {                 // (조건부) 주소
    postcode: '00000',       // 우편번호
    city: '...',             // 시/도
    address1: '...',         // 기본 주소
    address2: '...'          // 상세 주소
  },
  agreements: {
    MarketingByEmail: true,            // (필수) 이메일 마케팅 수신 동의
    MarketingByOnlineMessenger: true,  // (필수) 온라인 메신저 마케팅 수신 동의
    MarketingBySMS: true               // (필수) 문자 마케팅 수신 동의
  },
  // 본인인증이 필요한 경우 필수
  identityToken: '...'     // (조건부 필수) 본인인증을 통해 발급된 토큰
})

Sixshop Developers Portal