Page 26 -
P. 26

return;
                               }
                             }
                         });


                       Accounts.createUser 함수를 이용해서 사용자를 가입시켜보자.

                         Template.customSignUp.events({
                             "click button[name=signUp]" (evt,tmpl){
                               var username = tmpl.find('input[name=username]').value;
                               var email    = tmpl.find('input[name=email]').value;
                               var password = tmpl.find('input[name=password]').value;
                               var password2 = tmpl.find('input[name=password2]').value;
                               var name     = tmpl.find('input[name=name]').value;

                               if(password!=password2) {
                                  alert("패스워드를 확인하세요");
                                  return;
                               }

                               var userInfo = { username, email, password, profile : { name } };
                               Accounts.createUser(userInfo);
                             }                                                                          37
                         });


                       코드에서 보면 username은 미티어에서 로그인할 때 필요한 아이디다. email도 로그인에 사용할                          로그인 구현하기
                       수 있다.


                        노트  미티어의 로그인 아이디와 유일성 체크
                         미티어는 로그인 아이디(username)와 이메일(email) 모두 로그인할 때 사용할 수 있다. 이를 위해서 미티어는
                         createUser가 호출되면 서버 측에서 로그인 아이디와 이메일 모두 유일성을 확인한다.



                       Accounts.createUser 함수의 첫 번째 매개변수 형식은 다음과 같다.

                         ...생략...
                         var userInfo = { username, email, password, profile : { name } };
                         ...생략...









                                                                                                    549
   21   22   23   24   25   26   27   28   29   30   31