mirror of
https://github.com/HeyPuter/puter.git
synced 2025-01-24 15:20:21 +08:00
dev: make share feature flag reflect user state
This commit is contained in:
parent
14b962b459
commit
08779ac455
@ -42,8 +42,14 @@ class ShareService extends BaseService {
|
||||
// about whether or not a user has access to this feature
|
||||
const svc_featureFlag = this.services.get('feature-flag');
|
||||
svc_featureFlag.register('share', {
|
||||
$: 'config-flag',
|
||||
value: true
|
||||
$: 'function-flag',
|
||||
fn: async ({ actor }) => {
|
||||
const user = actor.type.user;
|
||||
if ( ! user ) {
|
||||
throw new Error('expected user');
|
||||
}
|
||||
return !! user.email_confirmed;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -264,6 +270,13 @@ class ShareService extends BaseService {
|
||||
if ( ! (actor.type instanceof UserActorType) ) {
|
||||
throw APIError.create('forbidden');
|
||||
}
|
||||
|
||||
if ( ! actor.type.user.email_confirmed ) {
|
||||
throw APIError.create('email_must_be_confirmed', null, {
|
||||
action: 'share something',
|
||||
});
|
||||
}
|
||||
|
||||
return await share_sequence.call(this, {
|
||||
actor, req, res,
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user