GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — meteor_study/ex_08_useAccount at master · gbox3d/meteor_study

Expand file tree

/

ex_08_useAccount

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

ex_08_useAccount

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
.meteor
.meteor
 
 
client
client
 
 
server
server
 
 
.gitignore
.gitignore
 
 
favicon.ico
favicon.ico
 
 
package.json
package.json
 
 
readme.md
readme.md
 
 

readme.md

Outline

manage user

필요 모듈 설치

meteor add [email protected]  
meteor add alanning:roles  

로그인처리

로그인

Meteor.loginWithPassword(
            evt.target.id.value, evt.target.passwd.value,
            function (err) {
                if(err) {
                    alert(err.reason);
                }
                else {
                    alert(`${Meteor.userId()} login `);
                }
            });

로그아웃

Meteor.logout()

로그인 정보 접근

html 상에서 현재 유져 데이터 접근은 {{currentUser}} 로 할수 있다.
클라이언트 측 스크립트상에서는 Meteor.userId(), Meteor.user() 로 접근 가능하다.
그러나 사용자 데이터중 profile 만 접근가능하다. 모든 정보를 얻으려면 해당 콜랙션을 구독 시켜야 한다.

//자신의 상세 정보 받아오기
Meteor.publish('users/userData', function() {

  return Meteor.users.find({_id:this.userId});
});
instance.subscribe("users/userData")

서버에서 특히 method 함수 안에서 this.userID 로 현재 클라이언트측에서 요청한 사용자의 아이디를 얻을수 있다. 이것은 요청 상대에 따라 그때그때 달라진다. 서버에서도 클라이언트 처럼 Meteor.userId(), Meteor.user() 역시 사용가능하다.

Meteor.methods({
"edit/user"({name,email}) {

    console.log(Meteor.userId())
    console.log(Meteor.user())
    console.log(this.userId)

    Meteor.users.update({
          _id: this.userId //현재 요청하는 아이디
        },
        {
          $set :  {
            "changeAt" : new Date(),
            "profile.name": name,
            "profile.email": email
          }
        });

    return {err: false,user : Meteor.user()}
  }
})
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.