Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
337
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
25
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TransFem.org
Sharkey
Commits
fa591e5c
Commit
fa591e5c
authored
8 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
アクセストークンは i に統一
トークンの先頭に ! がプリフィックスされているかどうかでユーザー固有のトークンかどうか判別する
parent
a63de6d7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
docs/api/getting-started.pug
+1
-1
1 addition, 1 deletion
docs/api/getting-started.pug
src/api/authenticate.ts
+10
-11
10 additions, 11 deletions
src/api/authenticate.ts
src/api/private/signup.ts
+1
-1
1 addition, 1 deletion
src/api/private/signup.ts
with
12 additions
and
13 deletions
docs/api/getting-started.pug
+
1
−
1
View file @
fa591e5c
...
...
@@ -71,4 +71,4 @@ block content
br
| 上手くいけば、認証したユーザーのアクセストークンがレスポンスとして取得できます。おめでとうございます!
p アクセストークンを取得できたら、あとは簡単です。REST APIなら、リクエストにアクセストークンを<code>
_userkey</code>(「自分のアクセストークンを取得したい場合」の方法で取得したアクセストークンの場合は<code>
i</code>
)
としてパラメータに含めるだけです。
p アクセストークンを取得できたら、あとは簡単です。REST APIなら、リクエストにアクセストークンを<code>i</code>としてパラメータに含めるだけです。
This diff is collapsed.
Click to expand it.
src/api/authenticate.ts
+
10
−
11
View file @
fa591e5c
...
...
@@ -20,10 +20,14 @@ export interface IAuthContext {
isSecure
:
boolean
;
}
export
default
(
req
:
express
.
Request
)
=>
new
Promise
<
IAuthContext
>
(
async
(
resolve
,
reject
)
=>
{
const
token
=
req
.
body
[
'
i
'
];
if
(
token
)
{
export
default
(
req
:
express
.
Request
)
=>
new
Promise
<
IAuthContext
>
(
async
(
resolve
,
reject
)
=>
{
const
token
=
req
.
body
[
'
i
'
]
||
req
.
body
[
'
_userkey
'
];
// そのうち_userkeyは削除
if
(
token
==
null
)
{
return
resolve
({
app
:
null
,
user
:
null
,
isSecure
:
false
});
}
if
(
token
[
0
]
==
'
!
'
)
{
const
user
=
await
User
.
findOne
({
token
:
token
});
...
...
@@ -36,12 +40,9 @@ export default (req: express.Request) =>
user
:
user
,
isSecure
:
true
});
}
const
userkey
=
req
.
headers
[
'
userkey
'
]
||
req
.
body
[
'
_userkey
'
];
if
(
userkey
)
{
}
else
{
const
userkeyDoc
=
await
Userkey
.
findOne
({
key
:
user
ke
y
key
:
to
ke
n
});
if
(
userkeyDoc
===
null
)
{
...
...
@@ -56,6 +57,4 @@ export default (req: express.Request) =>
return
resolve
({
app
:
app
,
user
:
user
,
isSecure
:
false
});
}
return
resolve
({
app
:
null
,
user
:
null
,
isSecure
:
false
});
});
This diff is collapsed.
Click to expand it.
src/api/private/signup.ts
+
1
−
1
View file @
fa591e5c
...
...
@@ -48,7 +48,7 @@ export default async (req: express.Request, res: express.Response) => {
const
hash
=
bcrypt
.
hashSync
(
password
,
salt
);
// Generate secret
const
secret
=
rndstr
(
'
a-zA-Z0-9
'
,
32
);
const
secret
=
'
!
'
+
rndstr
(
'
a-zA-Z0-9
'
,
32
);
// Create account
const
inserted
=
await
User
.
insert
({
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment