re-organize functions for auth use
Merge pull request #24 from zhouhao/dev-hao

re-organize functions for auth use